home *** CD-ROM | disk | FTP | other *** search
/ Kentucky Virtual Art Museum / Kentucky Virtual Art Museum.iso / site / museums / zoomify / hairjewelry.swf / scripts / ZoomifyViewerSymbol.as < prev   
Text File  |  2005-02-25  |  99KB  |  2,926 lines

  1. function ZoomifyViewerClass()
  2. {
  3.    if(this.gEnabled == undefined)
  4.    {
  5.       this.gEnabled = true;
  6.    }
  7.    this.gMouseEnabled = true;
  8.    this.syncTierMotionID = -1;
  9.    this.gSavedZoomToView = false;
  10.    this.gIsSlideshow = false;
  11.    this.gSetViewCalled = false;
  12.    this.gURLChanged = true;
  13.    this.gMustResetViewer = true;
  14.    this.gInitialized = false;
  15.    this.gInitCalled = false;
  16.    this.gOriginalPanMouseXScale = this.invisiblePanMouse_btn._xscale;
  17.    this.gOriginalPanMouseYScale = this.invisiblePanMouse_btn._yscale;
  18.    this.maskdummy_mc._visible = false;
  19.    this.tierdummy_mc._visible = false;
  20.    this.LabelTextDummy_mc._visible = false;
  21.    if(this._showSplash == false)
  22.    {
  23.       this.zoomifySplash_mc._visible = false;
  24.    }
  25.    this._isLivePreview = false;
  26.    this._swfURLShown = false;
  27.    if(this.gViewWidth == undefined)
  28.    {
  29.       this.gViewWidth = 500;
  30.    }
  31.    if(this.gViewHeight == undefined)
  32.    {
  33.       this.gViewHeight = 350;
  34.    }
  35.    this.gOriginalMovieWidth = this.gViewWidth;
  36.    this.gOriginalMovieHeight = this.gViewHeight;
  37.    this.gOffscreenX = 50000;
  38.    this._sizeChanged = false;
  39.    this.initKeyHandler();
  40.    this.gInitializeCallback = new Array();
  41.    this.gFocusCallback = new Array();
  42.    this.gRectCallback = new Array();
  43.    this.gViewCallback = new Array();
  44.    this.gStatusCallback = new Array();
  45.    this.gDownloadsCompleteCallback = new Array();
  46.    this.gCommServerCallback = new Array();
  47.    this.gCommServerMessageReceivedCallback = new Array();
  48.    this.gFormatCallback = new Array();
  49.    this.gMaxZoomCallback = new Array();
  50.    this.gMinZoomCallback = new Array();
  51.    this.gMouseCallback = new Array();
  52.    this.gKeyCallback = new Array();
  53.    this.gLabelVisibilityCallback = new Array();
  54.    this.gLabelMovedCallback = "";
  55.    this.gDoImmediateClipRemoval = false;
  56.    this.gTransitionList = new Array();
  57.    this.gNumTransitions = 0;
  58.    this.gCacheArray = new Array();
  59.    this.gCurrentCacheIndex = 0;
  60.    this.gCacheViewsIntervalID = -1;
  61.    if(this._initialX != undefined)
  62.    {
  63.       this.gSavedInitialX = this._initialX;
  64.    }
  65.    else
  66.    {
  67.       this.gSavedInitialX = 0;
  68.    }
  69.    if(this._initialY != undefined)
  70.    {
  71.       this.gSavedInitialY = this._initialY;
  72.    }
  73.    else
  74.    {
  75.       this.gSavedInitialY = 0;
  76.    }
  77.    if(this._initialZoom != undefined)
  78.    {
  79.       this.gSavedInitialZoom = this._initialZoom;
  80.    }
  81.    else
  82.    {
  83.       this.gSavedInitialZoom = -1;
  84.    }
  85.    this.gLabelVisibility = true;
  86.    this.gDoImmediateClipRemoval = false;
  87.    if(this.gComponentInitCallback != undefined)
  88.    {
  89.       this.gComponentInitCallback(this);
  90.    }
  91.    this.gPreserveCache = false;
  92.    this.gSkipHeader = false;
  93.    if(this.gCacheAllTiles == undefined)
  94.    {
  95.       this.gCacheAllTiles = false;
  96.    }
  97.    if(this._imagePath != "Enter /path/foldername or /path/imagename.extension" && this._imagePath != "" && this._imagePath != undefined)
  98.    {
  99.       this.init();
  100.    }
  101. }
  102. ZoomifyViewerClass.prototype = new MovieClip();
  103. Object.registerClass("ZoomifyViewerSymbol",ZoomifyViewerClass);
  104. ZoomifyViewerClass.prototype.setByteHandlerURL = function(url)
  105. {
  106.    this._byteHandlerURL = url;
  107.    this.gURLChanged = true;
  108. };
  109. ZoomifyViewerClass.prototype.getByteHandlerURL = function()
  110. {
  111.    return this._byteHandlerURL;
  112. };
  113. ZoomifyViewerClass.prototype.setImagePath = function(path)
  114. {
  115.    this._imagePath = path;
  116.    this.gURLChanged = true;
  117. };
  118. ZoomifyViewerClass.prototype.getImagePath = function()
  119. {
  120.    return this._imagePath;
  121. };
  122. ZoomifyViewerClass.prototype.setMapFilePath = function(path)
  123. {
  124.    this._mapFilePath = path;
  125.    this.gURLChanged = true;
  126. };
  127. ZoomifyViewerClass.prototype.getMapFilePath = function()
  128. {
  129.    return this._mapFilePath;
  130. };
  131. ZoomifyViewerClass.prototype.setSize = function(width, height)
  132. {
  133.    this._xscale = 100;
  134.    this.gViewWidth = width;
  135.    this._yscale = 100;
  136.    this.gViewHeight = height;
  137.    this._sizeChanged = true;
  138.    this.gMustResetViewer = true;
  139. };
  140. ZoomifyViewerClass.prototype.setFocus = function(focus)
  141. {
  142.    this._focus = focus;
  143.    if(this._focus == true)
  144.    {
  145.       i = 0;
  146.       while(i < this.gFocusCallback.length)
  147.       {
  148.          this.gFocusCallback[i](this);
  149.          i++;
  150.       }
  151.    }
  152. };
  153. ZoomifyViewerClass.prototype.getFocus = function()
  154. {
  155.    return this._focus;
  156. };
  157. ZoomifyViewerClass.prototype.setEnabled = function(enabled)
  158. {
  159.    this.gEnabled = enabled;
  160. };
  161. ZoomifyViewerClass.prototype.getEnabled = function()
  162. {
  163.    return this.gEnabled;
  164. };
  165. ZoomifyViewerClass.prototype.setMouseEnabled = function(mouseEnabled)
  166. {
  167.    this.gMouseEnabled = mouseEnabled;
  168. };
  169. ZoomifyViewerClass.prototype.getMouseEnabled = function()
  170. {
  171.    return this.gMouseEnabled;
  172. };
  173. ZoomifyViewerClass.prototype.setView = function(x, y, zoom)
  174. {
  175.    if(this.gEnabled == false)
  176.    {
  177.       return undefined;
  178.    }
  179.    if(this.gInitialized == true)
  180.    {
  181.       this.gPanPositionX = x;
  182.       this.gPanPositionY = y;
  183.       this.setZoom(zoom);
  184.       updateAfterEvent();
  185.    }
  186.    else
  187.    {
  188.       this.gSavedZoomToView = true;
  189.       this.gEndZoomX = x;
  190.       this.gEndZoomY = y;
  191.       this.gEndZoomZoom = zoom;
  192.       this.gZoomDuration = 0;
  193.       this.gZoomIntervalRate = 10;
  194.    }
  195. };
  196. ZoomifyViewerClass.prototype.setX = function(x)
  197. {
  198.    if(this.gEnabled == false)
  199.    {
  200.       return undefined;
  201.    }
  202.    this.gPanPositionX = x;
  203.    this.fillView();
  204.    updateAfterEvent();
  205. };
  206. ZoomifyViewerClass.prototype.setY = function(y)
  207. {
  208.    if(this.gEnabled == false)
  209.    {
  210.       return undefined;
  211.    }
  212.    this.gPanPositionY = y;
  213.    this.fillView();
  214.    updateAfterEvent();
  215. };
  216. ZoomifyViewerClass.prototype.setZoom = function(zoom)
  217. {
  218.    this.gZoom = zoom;
  219.    if(this.gInitialized == true && this.gEnabled == true)
  220.    {
  221.       var _loc4_ = undefined;
  222.       if(zoom == -1 || this._minZoom == -1)
  223.       {
  224.          _loc4_ = this.calculateScreenZoom();
  225.       }
  226.       if(this._minZoom == -1)
  227.       {
  228.          this._minZoom = _loc4_;
  229.       }
  230.       if(zoom == -1)
  231.       {
  232.          this.gZoom = _loc4_;
  233.       }
  234.       var _loc3_ = this.getTierWidth(this.gTierCount);
  235.       var _loc2_ = undefined;
  236.       _loc2_ = this.getTierWidth(this.gCurrentTier);
  237.       this.gCurrentTier_mc._xscale = this.gZoom * _loc3_ / _loc2_;
  238.       this.gCurrentTier_mc._yscale = this.gCurrentTier_mc._xscale;
  239.       _loc2_ = this.getTierWidth(this.gOldTier);
  240.       this.gCurrentTierOld_mc._xscale = this.gZoom * _loc3_ / _loc2_;
  241.       this.gCurrentTierOld_mc._yscale = this.gCurrentTierOld_mc._xscale;
  242.       _loc2_ = this.getTierWidth(this.gBackgroundTier);
  243.       this.gCurrentTierBackground_mc._xscale = this.gZoom * _loc3_ / _loc2_;
  244.       this.gCurrentTierBackground_mc._yscale = this.gCurrentTierBackground_mc._xscale;
  245.       this.gLabelTier_mc._xscale = this.gZoom * _loc3_ / _loc2_;
  246.       this.gLabelTier_mc._yscale = this.gLabelTier_mc._xscale;
  247.    }
  248. };
  249. ZoomifyViewerClass.prototype.getX = function()
  250. {
  251.    return this.gPanPositionX;
  252. };
  253. ZoomifyViewerClass.prototype.getY = function()
  254. {
  255.    return this.gPanPositionY;
  256. };
  257. ZoomifyViewerClass.prototype.getZoom = function()
  258. {
  259.    var _loc2_ = this.getTierWidth(this.gTierCount);
  260.    if(_loc2_ == 0)
  261.    {
  262.       return this._initialZoom;
  263.    }
  264.    var _loc3_ = this.getTierWidth(this.gBackgroundTier);
  265.    if(_loc3_ == 0)
  266.    {
  267.       return this._initialZoom;
  268.    }
  269.    var _loc4_ = this.gCurrentTierBackground_mc._xscale * _loc3_ / _loc2_;
  270.    return _loc4_;
  271. };
  272. ZoomifyViewerClass.prototype.setInitialX = function(x)
  273. {
  274.    this._initialX = x;
  275. };
  276. ZoomifyViewerClass.prototype.getInitialX = function()
  277. {
  278.    return this._initialX;
  279. };
  280. ZoomifyViewerClass.prototype.setInitialY = function(y)
  281. {
  282.    this._initialY = y;
  283. };
  284. ZoomifyViewerClass.prototype.getInitialY = function()
  285. {
  286.    return this._initialY;
  287. };
  288. ZoomifyViewerClass.prototype.setInitialZoom = function(zoom)
  289. {
  290.    this._initialZoom = zoom;
  291. };
  292. ZoomifyViewerClass.prototype.getInitialZoom = function()
  293. {
  294.    return this._initialZoom;
  295. };
  296. ZoomifyViewerClass.prototype.setMinZoom = function(minZoom)
  297. {
  298.    this._minZoom = minZoom;
  299. };
  300. ZoomifyViewerClass.prototype.getMinZoom = function()
  301. {
  302.    return this._minZoom;
  303. };
  304. ZoomifyViewerClass.prototype.setMaxZoom = function(maxZoom)
  305. {
  306.    this._maxZoom = maxZoom;
  307. };
  308. ZoomifyViewerClass.prototype.getMaxZoom = function()
  309. {
  310.    return this._maxZoom;
  311. };
  312. ZoomifyViewerClass.prototype.resetView = function()
  313. {
  314.    if(this.gInTransition == false && this.gEnabled == true)
  315.    {
  316.       this.stopZoomToView();
  317.       this.setView(this._initialX,this._initialY,this._initialZoom);
  318.       this.updateView();
  319.    }
  320. };
  321. ZoomifyViewerClass.prototype.updateView = function(preserveCache)
  322. {
  323.    if(preserveCache == undefined || preserveCache == "")
  324.    {
  325.       preserveCache = true;
  326.    }
  327.    if(this.gMustResetViewer == true || this.gURLChanged == true)
  328.    {
  329.       if(preserveCache == true)
  330.       {
  331.          this.gPreserveCache = true;
  332.       }
  333.       this.gSavedInitialX = this._initialX;
  334.       this.gSavedInitialY = this._initialY;
  335.       this.gSavedInitialZoom = this._initialZoom;
  336.       if(this.gInitialized == true)
  337.       {
  338.          if(this.gURLChanged == false)
  339.          {
  340.             this._initialX = this.getX();
  341.             this._initialY = this.getY();
  342.             this._initialZoom = this.getZoom();
  343.          }
  344.          this.destroy();
  345.       }
  346.       this.init();
  347.       this.gPreserveCache = false;
  348.       return undefined;
  349.    }
  350.    if(this.gInitialized == true)
  351.    {
  352.       if(this.gSetViewCalled == true)
  353.       {
  354.          this.panStop();
  355.          this.gSetViewCalled = false;
  356.       }
  357.       this.setTier();
  358.       this.fillView();
  359.       this._initialX = this.gSavedInitialX;
  360.       this._initialY = this.gSavedInitialY;
  361.       this._initialZoom = this.gSavedInitialZoom;
  362.    }
  363.    if(this._name.substring(0,20) != "ZoomifyTemporaryClip" && this._isLivePreview == false && (this._devFolderPath == undefined || this._devFolderPath == "" || this._devFolderPath == "Enables stage preview.  Control | Test Movie for value to enter.") && this._swfURLShown == false && this._imagePath.substring(0,4) != "http" && this._imagePath.substring(0,4) != "file")
  364.    {
  365.       this._swfURLShown = true;
  366.       trace("The Development Folder Path parameter in the ZoomifyViewer Component named \"" + this._name + "\" is empty.\nUse the following path to activate Live Preview:");
  367.       var _loc4_ = _root._url.split("/");
  368.       var _loc5_ = _loc4_[_loc4_.length - 1];
  369.       trace(_root._url.substring(0,_root._url.length - _loc5_.length));
  370.    }
  371. };
  372. ZoomifyViewerClass.prototype.calculateScreenZoom = function()
  373. {
  374.    var _loc3_ = undefined;
  375.    var _loc5_ = this.getTierWidth(this.gTierCount);
  376.    var _loc6_ = this.getTierHeight(this.gTierCount);
  377.    var _loc2_ = this.gViewWidth / _loc5_;
  378.    var _loc4_ = this.gViewHeight / _loc6_;
  379.    if(_loc2_ > _loc4_)
  380.    {
  381.       _loc3_ = _loc4_ * 100;
  382.    }
  383.    else
  384.    {
  385.       _loc3_ = _loc2_ * 100;
  386.    }
  387.    return _loc3_;
  388. };
  389. ZoomifyViewerClass.prototype.getViewWidth = function()
  390. {
  391.    return this.gViewWidth;
  392. };
  393. ZoomifyViewerClass.prototype.getViewHeight = function()
  394. {
  395.    return this.gViewHeight;
  396. };
  397. ZoomifyViewerClass.prototype.getTileSize = function()
  398. {
  399.    return this.gTileSize;
  400. };
  401. ZoomifyViewerClass.prototype.getWindowLeft = function()
  402. {
  403.    return this.gScaledWindowLeft;
  404. };
  405. ZoomifyViewerClass.prototype.getWindowTop = function()
  406. {
  407.    return this.gScaledWindowTop;
  408. };
  409. ZoomifyViewerClass.prototype.getWindowRight = function()
  410. {
  411.    return this.gScaledWindowRight;
  412. };
  413. ZoomifyViewerClass.prototype.getWindowBottom = function()
  414. {
  415.    return this.gScaledWindowBottom;
  416. };
  417. ZoomifyViewerClass.prototype.getTierCount = function()
  418. {
  419.    return this.gTierCount;
  420. };
  421. ZoomifyViewerClass.prototype.getTileCountHeight = function(tier)
  422. {
  423.    return this.gTileCountHeight[tier - 1];
  424. };
  425. ZoomifyViewerClass.prototype.getTileCountWidth = function(tier)
  426. {
  427.    return this.gTileCountWidth[tier - 1];
  428. };
  429. ZoomifyViewerClass.prototype.getTierWidth = function(tier)
  430. {
  431.    if(this.gTierCount < 1)
  432.    {
  433.       return 0;
  434.    }
  435.    return this.gTierWidth[tier - 1];
  436. };
  437. ZoomifyViewerClass.prototype.getTierHeight = function(tier)
  438. {
  439.    if(this.gTierCount < 1)
  440.    {
  441.       return 0;
  442.    }
  443.    return this.gTierHeight[tier - 1];
  444. };
  445. ZoomifyViewerClass.prototype.getTierTileCount = function(tier)
  446. {
  447.    return this.gTierTileCount[tier - 1];
  448. };
  449. ZoomifyViewerClass.prototype.getImageWidth = function()
  450. {
  451.    return this.gImageWidth;
  452. };
  453. ZoomifyViewerClass.prototype.getImageHeight = function()
  454. {
  455.    return this.gImageHeight;
  456. };
  457. ZoomifyViewerClass.prototype.getViewerState = function()
  458. {
  459.    return this.gViewerState;
  460. };
  461. ZoomifyViewerClass.prototype.zoomIn = function()
  462. {
  463.    var zoomFactor = 1.2;
  464.    if(this.gZoomFactor != -1)
  465.    {
  466.       zoomFactor = this.gZoomFactor;
  467.    }
  468.    if(this.gInitialized == true && (this.gInTransition == false || this.gZoomFactor != -1) && this.gEnabled == true)
  469.    {
  470.       if(this.gZoomFactor == -1)
  471.       {
  472.          this.stopZoomToView();
  473.       }
  474.       var currentZoom = this.getZoom();
  475.       var maxZoom = this._maxZoom;
  476.       if(maxZoom == -1)
  477.       {
  478.          maxZoom = this.calculateScreenZoom();
  479.       }
  480.       if(parseFloat(currentZoom) < parseFloat(maxZoom))
  481.       {
  482.          if(currentZoom * zoomFactor > maxZoom)
  483.          {
  484.             zoomFactor = maxZoom / currentZoom;
  485.          }
  486.          if(this.gCurrentTier > this.gBackgroundTier)
  487.          {
  488.             this.gCurrentTier_mc._xscale *= zoomFactor;
  489.             this.gCurrentTier_mc._yscale *= zoomFactor;
  490.          }
  491.          if(this.gOldTier > this.gBackgroundTier)
  492.          {
  493.             this.gCurrentTierOld_mc._xscale *= zoomFactor;
  494.             this.gCurrentTierOld_mc._yscale *= zoomFactor;
  495.          }
  496.          this.gCurrentTierBackground_mc._xscale *= zoomFactor;
  497.          this.gCurrentTierBackground_mc._yscale *= zoomFactor;
  498.          this.gLabelTier_mc._xscale *= zoomFactor;
  499.          this.gLabelTier_mc._yscale *= zoomFactor;
  500.          var currentZoom = this.getZoom();
  501.          if(currentZoom >= this._maxZoom)
  502.          {
  503.             i = 0;
  504.             while(i < this.gMaxZoomCallback.length)
  505.             {
  506.                this.gMaxZoomCallback[i](this,this._maxZoom);
  507.                i++;
  508.             }
  509.          }
  510.          updateAfterEvent();
  511.       }
  512.    }
  513. };
  514. ZoomifyViewerClass.prototype.zoomOut = function()
  515. {
  516.    var zoomFactor = 1.2;
  517.    if(this.gZoomFactor != -1)
  518.    {
  519.       zoomFactor = this.gZoomFactor;
  520.    }
  521.    if(this.gInitialized == true && (this.gInTransition == false || this.gZoomFactor != -1) && this.gEnabled == true)
  522.    {
  523.       if(this.gZoomFactor == -1)
  524.       {
  525.          this.stopZoomToView();
  526.       }
  527.       var currentZoom = this.getZoom();
  528.       var minZoom = this._minZoom;
  529.       if(minZoom == -1)
  530.       {
  531.          minZoom = this.calculateScreenZoom();
  532.       }
  533.       if(parseFloat(currentZoom) > parseFloat(minZoom))
  534.       {
  535.          if(currentZoom / zoomFactor < minZoom)
  536.          {
  537.             zoomFactor = currentZoom / minZoom;
  538.          }
  539.          if(this.gCurrentTier > this.gBackgroundTier)
  540.          {
  541.             this.gCurrentTier_mc._xscale /= zoomFactor;
  542.             this.gCurrentTier_mc._yscale /= zoomFactor;
  543.          }
  544.          if(this.gOldTier > this.gBackgroundTier)
  545.          {
  546.             this.gCurrentTierOld_mc._xscale /= zoomFactor;
  547.             this.gCurrentTierOld_mc._yscale /= zoomFactor;
  548.          }
  549.          this.gCurrentTierBackground_mc._xscale /= zoomFactor;
  550.          this.gCurrentTierBackground_mc._yscale /= zoomFactor;
  551.          this.gLabelTier_mc._xscale /= zoomFactor;
  552.          this.gLabelTier_mc._yscale /= zoomFactor;
  553.          currentZoom = this.getZoom();
  554.          if(currentZoom <= minZoom)
  555.          {
  556.             i = 0;
  557.             while(i < this.gMinZoomCallback.length)
  558.             {
  559.                this.gMinZoomCallback[i](this,this._minZoom);
  560.                i++;
  561.             }
  562.          }
  563.          updateAfterEvent();
  564.       }
  565.    }
  566. };
  567. ZoomifyViewerClass.prototype.panImage = function(x, y)
  568. {
  569.    if(this.gInitialized == true && this.gInTransition == false && this.gEnabled == true)
  570.    {
  571.       this.stopZoomToView();
  572.       var _loc2_ = this._rotation * 3.141592653589793 / 180;
  573.       this.gCurrentTier_mc._x += x * Math.cos(_loc2_) + y * Math.sin(_loc2_);
  574.       this.gCurrentTier_mc._y += y * Math.cos(_loc2_) - x * Math.sin(_loc2_);
  575.       this.gCurrentTierOld_mc._x = this.gCurrentTier_mc._x;
  576.       this.gCurrentTierBackground_mc._x = this.gCurrentTier_mc._x;
  577.       this.gLabelTier_mc._x = this.gCurrentTier_mc._x;
  578.       this.gCurrentTierOld_mc._y = this.gCurrentTier_mc._y;
  579.       this.gCurrentTierBackground_mc._y = this.gCurrentTier_mc._y;
  580.       this.gLabelTier_mc._y = this.gCurrentTier_mc._y;
  581.    }
  582. };
  583. ZoomifyViewerClass.prototype.panLeft = function()
  584. {
  585.    this.panImage(this.gViewWidth * (this.gCurrentTier_mc._xscale / 100) / 50,0);
  586. };
  587. ZoomifyViewerClass.prototype.panUp = function()
  588. {
  589.    this.panImage(0,this.gViewHeight * (this.gCurrentTier_mc._yscale / 100) / 50);
  590. };
  591. ZoomifyViewerClass.prototype.panDown = function()
  592. {
  593.    this.panImage(0,(- this.gViewHeight) * (this.gCurrentTier_mc._yscale / 100) / 50);
  594. };
  595. ZoomifyViewerClass.prototype.panRight = function()
  596. {
  597.    this.panImage((- this.gViewWidth) * (this.gCurrentTier_mc._xscale / 100) / 50,0);
  598. };
  599. ZoomifyViewerClass.prototype.panStop = function()
  600. {
  601.    if(this.gInitialized == true)
  602.    {
  603.       var _loc5_ = this.gCurrentTier_mc._x - this.gRegistrationPointX;
  604.       var _loc4_ = this.gCurrentTier_mc._y - this.gRegistrationPointY;
  605.       var _loc3_ = _loc5_ / (this.getTierWidth(this.gCurrentTier) * this.gCurrentTier_mc._xscale / 100);
  606.       var _loc2_ = _loc4_ / (this.getTierHeight(this.gCurrentTier) * this.gCurrentTier_mc._yscale / 100);
  607.       this.gPanPositionX = Number(this.gPanPositionX) + Number(_loc3_);
  608.       this.gPanPositionY = Number(this.gPanPositionY) + Number(_loc2_);
  609.       this.gCurrentTier_mc._x = this.gRegistrationPointX;
  610.       this.gCurrentTier_mc._y = this.gRegistrationPointY;
  611.       this.gCurrentTierOld_mc._x = this.gRegistrationPointX;
  612.       this.gCurrentTierOld_mc._y = this.gRegistrationPointY;
  613.       this.gCurrentTierBackground_mc._x = this.gRegistrationPointX;
  614.       this.gCurrentTierBackground_mc._y = this.gRegistrationPointY;
  615.       this.gLabelTier_mc._x = this.gRegistrationPointX;
  616.       this.gLabelTier_mc._y = this.gRegistrationPointY;
  617.    }
  618. };
  619. ZoomifyViewerClass.prototype.registerCallback = function(functionType, functionName)
  620. {
  621.    if(functionType == "Focus")
  622.    {
  623.       this.gFocusCallback.push(functionName);
  624.       if(this._focus == true && functionName != "")
  625.       {
  626.          functionName(this);
  627.       }
  628.       return this.gFocusCallback.length;
  629.    }
  630.    if(functionType == "View")
  631.    {
  632.       this.gViewCallback.push(functionName);
  633.       if(functionName != "" && this.gInitialized == true)
  634.       {
  635.          functionName(this,this.getX(),this.getY(),this.getZoom());
  636.       }
  637.       return this.gViewCallback.length;
  638.    }
  639.    if(functionType == "Rect")
  640.    {
  641.       this.gRectCallback.push(functionName);
  642.       if(functionName != "" && this.gInitialized == true)
  643.       {
  644.          functionName(this,this.getWindowLeft(),this.getWindowTop(),this.getWindowRight(),this.getWindowBottom());
  645.       }
  646.       return this.gRectCallback.length;
  647.    }
  648.    if(functionType == "Init")
  649.    {
  650.       this.gInitializeCallback.push(functionName);
  651.       return this.gInitializeCallback.length;
  652.    }
  653.    if(functionType == "Status")
  654.    {
  655.       this.gStatusCallback.push(functionName);
  656.       return this.gStatusCallback.length;
  657.    }
  658.    if(functionType == "DownloadComplete")
  659.    {
  660.       this.gDownloadsCompleteCallback.push(functionName);
  661.       return this.gDownloadsCompleteCallback.length;
  662.    }
  663.    if(functionType == "Communication")
  664.    {
  665.       this.gCommServerCallback.push(functionName);
  666.       return this.gCommServerCallback.length;
  667.    }
  668.    if(functionType == "CommunicationReceived")
  669.    {
  670.       this.gCommServerMessageReceivedCallback.push(functionName);
  671.       return this.gCommServerMessageReceivedCallback.length;
  672.    }
  673.    if(functionType == "MaxZoomReached")
  674.    {
  675.       this.gMaxZoomCallback.push(functionName);
  676.       return this.gMaxZoomCallback.length;
  677.    }
  678.    if(functionType == "MinZoomReached")
  679.    {
  680.       this.gMinZoomCallback.push(functionName);
  681.       return this.gMinZoomCallback.length;
  682.    }
  683.    if(functionType == "Mouse")
  684.    {
  685.       this.gMouseCallback.push(functionName);
  686.       return this.gMouseCallback.length;
  687.    }
  688.    if(functionType == "Key")
  689.    {
  690.       this.gKeyCallback.push(functionName);
  691.       return this.gKeyCallback.length;
  692.    }
  693.    if(functionType == "LabelVisibility")
  694.    {
  695.       this.gLabelVisibilityCallback.push(functionName);
  696.       return this.gLabelVisibilityCallback.length;
  697.    }
  698.    if(functionType == "LabelMoved")
  699.    {
  700.       this.gLabelMovedCallback = functionName;
  701.       var i = 0;
  702.       while(i < this.gLabelArray.length)
  703.       {
  704.          this.gLabelArray[i].gTextMovieClip.labelText_mc.gLabelMovedCallback = functionName;
  705.          i++;
  706.       }
  707.    }
  708.    else if(functionType.substring(0,6) == "Format")
  709.    {
  710.       var formatObject = new Object();
  711.       formatObject.extension = functionType.substring(7,10);
  712.       formatObject.callback = functionName;
  713.       this.gFormatCallback.push(formatObject);
  714.       return this.gFormatCallback.length;
  715.    }
  716. };
  717. ZoomifyViewerClass.prototype.unregisterCallback = function(functionType, id)
  718. {
  719.    if(functionType == "Focus")
  720.    {
  721.       this.gFocusCallback[id - 1] = "";
  722.    }
  723.    else if(functionType == "View")
  724.    {
  725.       this.gViewCallback[id - 1] = "";
  726.    }
  727.    else if(functionType == "Rect")
  728.    {
  729.       this.gRectCallback[id - 1] = "";
  730.    }
  731.    else if(functionType == "Init")
  732.    {
  733.       this.gInitializeCallback[id - 1] = "";
  734.    }
  735.    else if(functionType == "Status")
  736.    {
  737.       this.gStatusCallback[id - 1] = "";
  738.    }
  739.    else if(functionType == "DownloadComplete")
  740.    {
  741.       this.gDownloadsCompleteCallback[id - 1] = "";
  742.    }
  743.    else if(functionType == "Communication")
  744.    {
  745.       this.gCommServerCallback[id - 1] = "";
  746.    }
  747.    else if(functionType == "Mouse")
  748.    {
  749.       this.gMouseCallback[id - 1] = "";
  750.    }
  751.    else if(functionType == "Key")
  752.    {
  753.       this.gKeyCallback[id - 1] = "";
  754.    }
  755.    else if(functionType == "LabelVisibility")
  756.    {
  757.       this.gLabelVisibilityCallback[id - 1] = "";
  758.    }
  759.    else if(functionType == "CommunicationReceived")
  760.    {
  761.       this.gCommServerMessageReceivedCallback[id - 1] = "";
  762.    }
  763.    else if(functionType == "LabelMoved")
  764.    {
  765.       this.gLabelMovedCallback = "";
  766.    }
  767.    else if(functionType.substring(0,6) == "Format")
  768.    {
  769.       delete this.gFormatCallback[id - 1];
  770.       this.gFormatCallback[id - 1] = undefined;
  771.    }
  772.    else if(functionType == "MaxZoomReached")
  773.    {
  774.       this.gMaxZoomCallback[id - 1] = "";
  775.    }
  776.    else if(functionType == "MinZoomReached")
  777.    {
  778.       this.gMinZoomCallback[id - 1] = "";
  779.    }
  780. };
  781. ZoomifyViewerClass.prototype.addLabel = function(labelNode)
  782. {
  783.    this.addLabelByXML(labelNode);
  784. };
  785. ZoomifyViewerClass.prototype.addLabelByXML = function(labelNode)
  786. {
  787.    var _loc13_ = parseFloat(labelNode.attributes.x);
  788.    var _loc11_ = parseFloat(labelNode.attributes.y);
  789.    var _loc4_ = parseInt(labelNode.attributes.xscale);
  790.    var _loc3_ = parseInt(labelNode.attributes.yscale);
  791.    var _loc7_ = parseFloat(labelNode.attributes.zoom);
  792.    var _loc8_ = unescape(labelNode.attributes.movieClip);
  793.    var _loc6_ = labelNode.attributes.id;
  794.    var _loc12_ = labelNode.attributes.url;
  795.    var _loc5_ = unescape(labelNode.attributes.name);
  796.    var _loc9_ = parseInt(labelNode.attributes.textColor);
  797.    var _loc10_ = parseInt(labelNode.attributes.textBackgroundColor);
  798.    this.addLabelByParams(_loc13_,_loc11_,_loc4_,_loc3_,_loc7_,_loc8_,_loc6_,_loc12_,_loc5_,_loc9_,_loc10_);
  799. };
  800. ZoomifyViewerClass.prototype.addLabelByParams = function(xOffset, yOffset, xScale, yScale, zoom, movieClipString, id, url, text, textColor, textBackgroundColor)
  801. {
  802.    if(this.gCurrentTierBackground_mc != undefined)
  803.    {
  804.       var clipIndex = this.gLabelArray.length * 10;
  805.       if(this.gLabelArray.length > 0)
  806.       {
  807.          this.gLabelArray[this.gLabelArray.length - 1] + 1;
  808.       }
  809.       var labelClipName = "label" + id + "_mc";
  810.       var mcLabelImageString = "this.gLabelTier_mc.labels_mc";
  811.       var mcLabelImage = eval(mcLabelImageString);
  812.       var mcMyLabelImage;
  813.       mcLabelImage.attachMovie("emptyLabel_mc",labelClipName,100 + 2 * this.gLabelArray.length);
  814.       mcLabelImage.attachMovie("LabelText_mc","text_for_" + labelClipName,10000 + 2 * this.gLabelArray.length);
  815.       mcMyLabelImage = eval(mcLabelImageString + "." + labelClipName);
  816.       mcMyLabelText = eval(mcLabelImageString + ".text_for_" + labelClipName);
  817.       var xWidth = this.getTierWidth(this.gBackgroundTier);
  818.       var yHeight = this.getTierHeight(this.gBackgroundTier);
  819.       var zoomScale = this.getZoom() / zoom;
  820.       mcMyLabelImage._x = xWidth / 2 - xOffset * xWidth;
  821.       mcMyLabelImage._y = yHeight / 2 - yOffset * yHeight;
  822.       mcMyLabelImage._xscale = zoomScale * xScale / (this.gCurrentTierBackground_mc._xscale / 100);
  823.       mcMyLabelImage._yscale = zoomScale * yScale / (this.gCurrentTierBackground_mc._yscale / 100);
  824.       mcMyLabelImage._visible = true;
  825.       mcMyLabelImage.gZoomifyURL = unescape(url);
  826.       mcMyLabelImage.gMovieClipString = movieClipString;
  827.       mcMyLabelImage.gMovieLevel = 100 + 2 * this.gLabelArray.length;
  828.       if(text != "")
  829.       {
  830.          mcMyLabelText.labelText_mc._labelText.text = text;
  831.          mcMyLabelText.labelText_mc._labelText.textColor = textColor;
  832.          mcMyLabelText.labelText_mc._labelText.backgroundColor = textBackgroundColor;
  833.          mcMyLabelText._x = xWidth / 2 - xOffset * xWidth;
  834.          mcMyLabelText._y = yHeight / 2 - yOffset * yHeight;
  835.          mcMyLabelText._xscale = zoomScale * xScale / (this.gCurrentTierBackground_mc._xscale / 100);
  836.          mcMyLabelText._yscale = zoomScale * yScale / (this.gCurrentTierBackground_mc._yscale / 100);
  837.          mcMyLabelText._visible = true;
  838.       }
  839.       else
  840.       {
  841.          mcMyLabelText._visible = false;
  842.       }
  843.       mcMyLabelText.labelText_mc.gLabelsEditableFlag = false;
  844.       mcMyLabelText.labelText_mc.gLabelMovedCallback = this.gLabelMovedCallback;
  845.       mcMyLabelText.labelText_mc.gBackgroundTierWidth = this.getTierWidth(this.gBackgroundTier);
  846.       mcMyLabelText.labelText_mc.gBackgroundTierHeight = this.getTierHeight(this.gBackgroundTier);
  847.       mcMyLabelText.labelText_mc.gGraphicMovieClip = mcMyLabelImage;
  848.       mcMyLabelText.labelText_mc.gZoomifyURL = unescape(url);
  849.       mcMyLabelImage.gTextMovieClip = mcMyLabelText;
  850.       this.gLabelArray.push(mcMyLabelImage);
  851.    }
  852. };
  853. ZoomifyViewerClass.prototype.setLabelProperty = function(id, property, value)
  854. {
  855.    var mcMyLabelImageString = "this.gLabelTier_mc.labels_mc.label" + id + "_mc";
  856.    var mcMyLabelTextString = "this.gLabelTier_mc.labels_mc.text_for_label" + id + "_mc";
  857.    var theLabel = eval(mcMyLabelImageString);
  858.    var theTextLabel = eval(mcMyLabelTextString);
  859.    var xWidth = this.getTierWidth(this.gBackgroundTier);
  860.    var yHeight = this.getTierHeight(this.gBackgroundTier);
  861.    var zoomScale = this.getZoom() / zoom;
  862.    if(property == "x")
  863.    {
  864.       theLabel._x = xWidth / 2 - value * xWidth;
  865.       theTextLabel._x = theLabel._x;
  866.    }
  867.    else if(property == "y")
  868.    {
  869.       theLabel._y = yHeight / 2 - value * yHeight;
  870.       theTextLabel._y = theLabel._y;
  871.    }
  872.    else if(property == "xscale")
  873.    {
  874.       theLabel._xscale *= value;
  875.       theTextLabel._xscale = theLabel._xscale;
  876.    }
  877.    else if(property == "yscale")
  878.    {
  879.       theLabel._yscale *= value;
  880.       theTextLabel._yscale = theLabel._yscale;
  881.    }
  882.    else if(property == "url")
  883.    {
  884.       theTextLabel.labelText_mc.gZoomifyURL = unescape(value);
  885.       theLabel.gZoomifyURL = unescape(value);
  886.    }
  887.    else if(property == "textColor")
  888.    {
  889.       theTextLabel.labelText_mc._labelText.textColor = value;
  890.    }
  891.    else if(property == "textBackgroundColor")
  892.    {
  893.       theTextLabel.labelText_mc._labelText.backgroundColor = value;
  894.    }
  895.    else if(property == "name")
  896.    {
  897.       theTextLabel.labelText_mc._labelText.text = value;
  898.    }
  899. };
  900. ZoomifyViewerClass.prototype.setLabelVisibility = function(visibleFlag)
  901. {
  902.    var mcMyLabelImageString = "this.gLabelTier_mc";
  903.    var theLabel = eval(mcMyLabelImageString);
  904.    theLabel._visible = visibleFlag;
  905.    if(this.gLabelVisibility != visibleFlag)
  906.    {
  907.       this.gLabelVisibility = visibleFlag;
  908.       i = 0;
  909.       while(i < this.gLabelVisibilityCallback.length)
  910.       {
  911.          this.gLabelVisibilityCallback[i](this,visibleFlag);
  912.          i++;
  913.       }
  914.    }
  915. };
  916. ZoomifyViewerClass.prototype.getLabelVisibility = function()
  917. {
  918.    return this.gLabelVisibility;
  919. };
  920. ZoomifyViewerClass.prototype.removeLabel = function(id)
  921. {
  922.    var mcMyLabelImageString = "this.gLabelTier_mc.labels_mc.label" + id + "_mc";
  923.    var theLabel = eval(mcMyLabelImageString);
  924.    var i = 0;
  925.    while(i < this.gLabelArray.length)
  926.    {
  927.       if(this.gLabelArray[i] == theLabel)
  928.       {
  929.          theLabel.gTextMovieClip.removeMovieClip();
  930.          theLabel.removeMovieClip();
  931.          this.gLabelArray.splice(i,1);
  932.          return undefined;
  933.       }
  934.       i++;
  935.    }
  936. };
  937. ZoomifyViewerClass.prototype.getLabelEditMode = function(id)
  938. {
  939.    var mcMyLabelImageString = "this.gLabelTier_mc.labels_mc.label" + id + "_mc";
  940.    var theLabel = eval(mcMyLabelImageString);
  941.    return theLabel.gTextMovieClip.labelText_mc.gLabelsEditableFlag;
  942. };
  943. ZoomifyViewerClass.prototype.setLabelEditMode = function(id, editFlag)
  944. {
  945.    var mcMyLabelImageString = "this.gLabelTier_mc.labels_mc.label" + id + "_mc";
  946.    var theLabel = eval(mcMyLabelImageString);
  947.    theLabel.gTextMovieClip.labelText_mc.gLabelsEditableFlag = editFlag;
  948. };
  949. ZoomifyViewerClass.prototype.removeAllLabels = function()
  950. {
  951.    var _loc2_ = 0;
  952.    while(_loc2_ < this.gLabelArray.length)
  953.    {
  954.       this.gLabelArray[_loc2_].gTextMovieClip.removeMovieClip();
  955.       this.gLabelArray[_loc2_].removeMovieClip();
  956.       _loc2_ = _loc2_ + 1;
  957.    }
  958.    delete this.gLabelArray;
  959.    this.gLabelArray = new Array();
  960. };
  961. ZoomifyViewerClass.prototype.initKeyHandler = function()
  962. {
  963.    keyListener = new Object();
  964.    keyListener.owner = this;
  965.    keyListener.onKeyDown = function()
  966.    {
  967.       this.owner.myOnKeyDown();
  968.    };
  969.    keyListener.onKeyUp = function()
  970.    {
  971.       this.owner.myOnKeyUp();
  972.    };
  973.    Key.addListener(keyListener);
  974. };
  975. ZoomifyViewerClass.prototype.myOnKeyDown = function()
  976. {
  977.    if(this._focus == false || this.gEnabled == false || this.gInTransition == true)
  978.    {
  979.       return undefined;
  980.    }
  981.    var i;
  982.    switch(Key.getCode())
  983.    {
  984.       case 37:
  985.          this.panLeft();
  986.          updateAfterEvent();
  987.          i = 0;
  988.          while(i < this.gKeyCallback.length)
  989.          {
  990.             this.gKeyCallback[i](this,"down",Key.getCode());
  991.             i++;
  992.          }
  993.          break;
  994.       case 38:
  995.          this.panUp();
  996.          updateAfterEvent();
  997.          i = 0;
  998.          while(i < this.gKeyCallback.length)
  999.          {
  1000.             this.gKeyCallback[i](this,"down",Key.getCode());
  1001.             i++;
  1002.          }
  1003.          break;
  1004.       case 39:
  1005.          this.panRight();
  1006.          updateAfterEvent();
  1007.          i = 0;
  1008.          while(i < this.gKeyCallback.length)
  1009.          {
  1010.             this.gKeyCallback[i](this,"down",Key.getCode());
  1011.             i++;
  1012.          }
  1013.          break;
  1014.       case 40:
  1015.          this.panDown();
  1016.          updateAfterEvent();
  1017.          i = 0;
  1018.          while(i < this.gKeyCallback.length)
  1019.          {
  1020.             this.gKeyCallback[i](this,"down",Key.getCode());
  1021.             i++;
  1022.          }
  1023.          break;
  1024.       case 65:
  1025.          this.zoomIn();
  1026.          updateAfterEvent();
  1027.          i = 0;
  1028.          while(i < this.gKeyCallback.length)
  1029.          {
  1030.             this.gKeyCallback[i](this,"down",Key.getCode());
  1031.             i++;
  1032.          }
  1033.          break;
  1034.       case 90:
  1035.          this.zoomOut();
  1036.          updateAfterEvent();
  1037.          i = 0;
  1038.          while(i < this.gKeyCallback.length)
  1039.          {
  1040.             this.gKeyCallback[i](this,"down",Key.getCode());
  1041.             i++;
  1042.          }
  1043.          break;
  1044.       case 16:
  1045.          this.zoomIn();
  1046.          updateAfterEvent();
  1047.          i = 0;
  1048.          while(i < this.gKeyCallback.length)
  1049.          {
  1050.             this.gKeyCallback[i](this,"down",Key.getCode());
  1051.             i++;
  1052.          }
  1053.          break;
  1054.       case 17:
  1055.          this.zoomOut();
  1056.          updateAfterEvent();
  1057.          i = 0;
  1058.          while(i < this.gKeyCallback.length)
  1059.          {
  1060.             this.gKeyCallback[i](this,"down",Key.getCode());
  1061.             i++;
  1062.          }
  1063.    }
  1064. };
  1065. ZoomifyViewerClass.prototype.myOnKeyUp = function()
  1066. {
  1067.    if(this._focus == false || this.gEnabled == false || this.gInTransition == true)
  1068.    {
  1069.       return undefined;
  1070.    }
  1071.    var i;
  1072.    switch(Key.getCode())
  1073.    {
  1074.       case 72:
  1075.          if(this.getLabelVisibility() == false)
  1076.          {
  1077.             this.setLabelVisibility(true);
  1078.          }
  1079.          else
  1080.          {
  1081.             this.setLabelVisibility(false);
  1082.          }
  1083.          break;
  1084.       case 27:
  1085.          this.resetView();
  1086.          break;
  1087.       case 37:
  1088.       case 38:
  1089.       case 39:
  1090.       case 40:
  1091.       case 65:
  1092.       case 90:
  1093.       case 16:
  1094.       case 17:
  1095.          this.panStop();
  1096.          this.updateView();
  1097.          updateAfterEvent();
  1098.          i = 0;
  1099.          while(i < this.gKeyCallback.length)
  1100.          {
  1101.             this.gKeyCallback[i](this,"up",Key.getCode());
  1102.             i++;
  1103.          }
  1104.    }
  1105. };
  1106. ZoomifyViewerClass.prototype.MousePan = function(panEvent)
  1107. {
  1108.    if(this.gInitialized == true && this.gEnabled == true)
  1109.    {
  1110.       if(this.gInTransition == false)
  1111.       {
  1112.          if(panEvent == "start")
  1113.          {
  1114.             if(this.gMouseEnabled)
  1115.             {
  1116.                this.gMouseStartX = _root._xmouse;
  1117.                this.gMouseStartY = _root._ymouse;
  1118.                this.stopZoomToView();
  1119.                this.gCurrentTier_mc.startDrag();
  1120.                this.syncTierMotionID = setInterval(this,"syncTierMotion",1);
  1121.                this.setFocus(true);
  1122.             }
  1123.          }
  1124.       }
  1125.       if(panEvent == "stop")
  1126.       {
  1127.          if(this.gMouseEnabled && this.syncTierMotionID != -1)
  1128.          {
  1129.             this.gCurrentTier_mc.stopDrag();
  1130.             clearInterval(this.syncTierMotionID);
  1131.             this.syncTierMotionID = -1;
  1132.             this.panStop();
  1133.             if(_root._xmouse - this.gMouseStartX < 3 && _root._xmouse - this.gMouseStartX > -3 && _root._ymouse - this.gMouseStartY < 3 && _root._ymouse - this.gMouseStartY > -3)
  1134.             {
  1135.                var currentZoom = this.getZoom();
  1136.                if(currentZoom == -1)
  1137.                {
  1138.                   currentZoom = this.calculateScreenZoom();
  1139.                }
  1140.                var testZoom = 400;
  1141.                while(testZoom > currentZoom)
  1142.                {
  1143.                   testZoom /= 2;
  1144.                }
  1145.                testZoom *= 2;
  1146.                if(testZoom > this._maxZoom)
  1147.                {
  1148.                   testZoom = this._maxZoom;
  1149.                }
  1150.                var x = 0.5 - (this.getWindowLeft() + (this.getWindowRight() - this.getWindowLeft()) * (_root._xmouse - (this._x - this.gViewWidth / 2)) / this.gViewWidth);
  1151.                var y = 0.5 - (this.getWindowTop() + (this.getWindowBottom() - this.getWindowTop()) * (_root._ymouse - (this._y - this.gViewHeight / 2)) / this.gViewHeight);
  1152.                this.setView(x,y,testZoom);
  1153.             }
  1154.             this.updateView();
  1155.          }
  1156.       }
  1157.    }
  1158.    var i = 0;
  1159.    while(i < this.gMouseCallback.length)
  1160.    {
  1161.       this.gMouseCallback[i](this,panEvent);
  1162.       i++;
  1163.    }
  1164. };
  1165. ZoomifyViewerClass.prototype.syncTierMotion = function()
  1166. {
  1167.    if(this.gMouseEnabled)
  1168.    {
  1169.       this.gCurrentTierOld_mc._x = this.gCurrentTier_mc._x;
  1170.       this.gCurrentTierOld_mc._y = this.gCurrentTier_mc._y;
  1171.       this.gCurrentTierBackground_mc._x = this.gCurrentTier_mc._x;
  1172.       this.gCurrentTierBackground_mc._y = this.gCurrentTier_mc._y;
  1173.       this.gLabelTier_mc._x = this.gCurrentTier_mc._x;
  1174.       this.gLabelTier_mc._y = this.gCurrentTier_mc._y;
  1175.    }
  1176.    var i = 0;
  1177.    while(i < this.gMouseCallback.length)
  1178.    {
  1179.       this.gMouseCallback[i](this,"stilldown");
  1180.       i++;
  1181.    }
  1182. };
  1183. ZoomifyViewerClass.prototype.init = function()
  1184. {
  1185.    this.gHaltViewMessages = true;
  1186.    this.gLastViewSent = "First Message";
  1187.    var tempRotation = this._rotation;
  1188.    this._rotation = 0;
  1189.    if(this._sizeChanged == false)
  1190.    {
  1191.       this.setSize(this._width,this._height);
  1192.    }
  1193.    this._rotation = tempRotation;
  1194.    this.attachMovie("mask_mc","mask_mc",15002);
  1195.    this.mask_mc._width = this.gViewWidth;
  1196.    this.mask_mc._height = this.gViewHeight;
  1197.    this.setMask(this.mask_mc);
  1198.    if(this._imagePath == "Enter /path/foldername or /path/imagename.extension" || this._imagePath == "" || this._imagePath == undefined)
  1199.    {
  1200.       return undefined;
  1201.    }
  1202.    this.gTileCountWidth = new Array();
  1203.    this.gTileCountHeight = new Array();
  1204.    this.gTierTileCount = new Array();
  1205.    this.gTierWidth = new Array();
  1206.    this.gTierHeight = new Array();
  1207.    this.gTileCacheoffsetIndex = new Array();
  1208.    this.gOffsetChunkArray = new Array();
  1209.    this.gTilesUsedArray1 = new Array();
  1210.    this.gTilesUsedArray2 = new Array();
  1211.    this.gTilesUsedOldTierArray1 = new Array();
  1212.    this.gTilesUsedOldTierArray2 = new Array();
  1213.    this.gLabelArray = new Array();
  1214.    this.gMetersPerPixel = new Array();
  1215.    this.gViewerState = 0;
  1216.    this.gHeaderSize = 0;
  1217.    this.gNumImages = 0;
  1218.    this.gNumTotalTiles = 0;
  1219.    this.gImageWidth = 0;
  1220.    this.gImageHeight = 0;
  1221.    this.gTierCount = 0;
  1222.    this.gCurrentTierArray = 1;
  1223.    this.gKeyDown = 0;
  1224.    this.gOffsetY = 0;
  1225.    this.gOffsetX = 0;
  1226.    this.gStartTier = 1;
  1227.    this.gCurrentTier = 1;
  1228.    this.gBackgroundTier = 1;
  1229.    this.gOldTier = 1;
  1230.    this.gRegistrationPointY = 0;
  1231.    this.gPanPositionX = 0;
  1232.    this.gPanPositionY = 0;
  1233.    this.gZoom = -1;
  1234.    this.gTileSize = 64;
  1235.    this.gCurrentTier_mc = undefined;
  1236.    this.gCurrentTierOld_mc = undefined;
  1237.    this.gCurrentTierBackground_mc = undefined;
  1238.    this.gRegistrationPointX = 0;
  1239.    this.gMustResetViewer = false;
  1240.    this.gURLChanged = false;
  1241.    this.gSwapTierPercent = 100;
  1242.    this.gZoomToViewIntervalID = -1;
  1243.    this.gMinTier = 1;
  1244.    this.gInitialized = false;
  1245.    this.gInitCalled = true;
  1246.    var tempTier_mc;
  1247.    this.numPremadeLevels = 20;
  1248.    i = 1;
  1249.    while(i < this.numPremadeLevels)
  1250.    {
  1251.       var movieClipString = "tier" + i + "_mc";
  1252.       tempTier_mc = eval("this." + movieClipString);
  1253.       if(tempTier_mc == undefined)
  1254.       {
  1255.          this.attachMovie("tier_mc","tier" + i + "_mc",i);
  1256.          tempTier_mc = eval("this." + movieClipString);
  1257.       }
  1258.       tempTier_mc._x = 0;
  1259.       tempTier_mc._y = 0;
  1260.       tempTier_mc._width = this.gViewWidth;
  1261.       tempTier_mc._height = this.gViewHeight;
  1262.       tempTier_mc._xscale = 100;
  1263.       tempTier_mc._yscale = 100;
  1264.       tempTier_mc._visible = false;
  1265.       tempTier_mc._quality = "BEST";
  1266.       i++;
  1267.    }
  1268.    this.attachMovie("tier_mc","gLabelTier_mc",9000);
  1269.    this.gLabelTier_mc._x = 0;
  1270.    this.gLabelTier_mc._y = 0;
  1271.    this.gLabelTier_mc._xscale = 100;
  1272.    this.gLabelTier_mc._yscale = 100;
  1273.    this.gLabelTier_mc._width = this.gViewWidth;
  1274.    this.gLabelTier_mc._height = this.gViewHeight;
  1275.    this.gLabelTier_mc._quality = "BEST";
  1276.    this.gLabelTier_mc.attachMovie("tier_mc","labels_mc",9001);
  1277.    this.gLabelTier_mc.labels_mc._visible = true;
  1278.    this.gLabelTier_mc._visible = this.gLabelVisibility;
  1279.    this.invisiblePanMouse_btn._xscale = this.gOriginalPanMouseXScale * this.gViewWidth / this.gOriginalMovieWidth;
  1280.    this.invisiblePanMouse_btn._yscale = this.gOriginalPanMouseYScale * this.gViewHeight / this.gOriginalMovieHeight;
  1281.    if(this.gTileQueue == undefined)
  1282.    {
  1283.       this.gTileQueue = new Array();
  1284.    }
  1285.    if(this.gTileQueueIntervalID == undefined)
  1286.    {
  1287.       this.gTileQueueIntervalID = -1;
  1288.    }
  1289.    if(this.gLastTileTime == undefined)
  1290.    {
  1291.       this.gLastTileTime = -1;
  1292.    }
  1293.    if(this.gMaxTileQueueLength == undefined)
  1294.    {
  1295.       this.gMaxTileQueueLength = 0;
  1296.    }
  1297.    this.gZoomStartTime = -1;
  1298.    this.gInTransition = false;
  1299.    this.gZoomFactor = -1;
  1300.    this.gOldEnabled = this.gEnabled;
  1301.    var showPreloader = false;
  1302.    var cacheArray = new Array();
  1303.    if(this.gCurrentCacheIndex == undefined)
  1304.    {
  1305.       this.gCurrentCacheIndex = 0;
  1306.    }
  1307.    if(this.gPreserveCache == false)
  1308.    {
  1309.       if(this.gTileQueue != undefined)
  1310.       {
  1311.          delete this.gTileQueue;
  1312.       }
  1313.       this.gTileQueue = new Array();
  1314.       this.gTileQueueIntervalID = -1;
  1315.       this.gLastTileTime = -1;
  1316.       this.gMaxTileQueueLength = 0;
  1317.       this.gNumTransitions = 0;
  1318.       this.gCacheViewsIntervalID = -1;
  1319.       i = 0;
  1320.       while(i < this._transitionName.length)
  1321.       {
  1322.          var transitionObject = new Object();
  1323.          transitionObject.fromX = parseFloat(this._fromX[i]);
  1324.          transitionObject.fromY = parseFloat(this._fromY[i]);
  1325.          transitionObject.fromZoom = parseFloat(this._fromZoom[i]);
  1326.          transitionObject.fromDuration = parseInt(this._fromDuration[i]);
  1327.          transitionObject.toX = parseFloat(this._toX[i]);
  1328.          transitionObject.toY = parseFloat(this._toY[i]);
  1329.          transitionObject.toZoom = parseFloat(this._toZoom[i]);
  1330.          transitionObject.toViewName = this._transitionName[i] + "_view";
  1331.          transitionObject.toImagePath = this._toImagePath[i];
  1332.          transitionObject.imageEffectDuration = parseInt(this._imageEffectDuration[i]);
  1333.          transitionObject.imageEffectType = this._imageEffectType[i];
  1334.          transitionObject.imageEffectParam = this._imageEffectParam1[i];
  1335.          transitionObject.imageEffectParam2 = this._imageEffectParam2[i];
  1336.          transitionObject.imageEffectCompleteCallback = this._imageEffectCompleteCallback[i];
  1337.          transitionObject.zoomCompleteCallback = this._zoomCompleteCallback[i];
  1338.          transitionObject.name = this._transitionName[i];
  1339.          this.addTransition(transitionObject);
  1340.          if(this._precacheTransitions == true || this._preloadTransitions == true)
  1341.          {
  1342.             var index = cacheArray.length;
  1343.             cacheArray[index] = new Object();
  1344.             cacheArray[index].x = transitionObject.toX;
  1345.             cacheArray[index].y = transitionObject.toY;
  1346.             cacheArray[index].zoom = transitionObject.toZoom;
  1347.             if(transitionObject.toImagePath == "")
  1348.             {
  1349.                cacheArray[index].imagePath = this._imagePath;
  1350.             }
  1351.             else
  1352.             {
  1353.                cacheArray[index].imagePath = transitionObject.toImagePath;
  1354.             }
  1355.             cacheArray[index].name = transitionObject.toViewName;
  1356.          }
  1357.          i++;
  1358.       }
  1359.    }
  1360.    if(cacheArray.length > 0)
  1361.    {
  1362.       if(this._preloadTransitions == true)
  1363.       {
  1364.          this.gCurrentTierOld_mc._visible = false;
  1365.          this.gCurrentTierBackground_mc._visible = false;
  1366.          this.gCurrentTier_mc._visible = false;
  1367.          this.gLabelTier_mc._visible = false;
  1368.          this.gOldEnabled = this.gEnabled;
  1369.          this.gEnabled = false;
  1370.          this.zoomifySplash_mc.preloadText_txt.text = "Preloading 0% done";
  1371.          this.cacheViews(cacheArray,"this.preloadProgress");
  1372.       }
  1373.       else
  1374.       {
  1375.          this.cacheViews(cacheArray,"");
  1376.       }
  1377.    }
  1378.    this.gDelayStart = false;
  1379.    if(this.gSkipHeader == false)
  1380.    {
  1381.       if(this.gInitialHeaderIntervalID != -1 && this.gInitialHeaderIntervalID != undefined)
  1382.       {
  1383.          clearInterval(this.gInitialHeaderIntervalID);
  1384.          this.gInitialHeaderIntervalID = -1;
  1385.       }
  1386.       this.gInitialHeaderIntervalID = setInterval(this,"getHeader",10);
  1387.    }
  1388. };
  1389. ZoomifyViewerClass.prototype.preloadProgress = function(instance, percentDone)
  1390. {
  1391.    this.zoomifySplash_mc.preloadText_txt.text = "Preloading " + percentDone + "% done";
  1392.    if(percentDone == 100)
  1393.    {
  1394.       this.gCurrentTierOld_mc._visible = true;
  1395.       this.gCurrentTierBackground_mc._visible = true;
  1396.       this.gCurrentTier_mc._visible = true;
  1397.       this.gLabelTier_mc._visible = this.gLabelVisibility;
  1398.       this.zoomifySplash_mc._visible = false;
  1399.       this.gEnabled = this.gOldEnabled;
  1400.       this.updateView();
  1401.    }
  1402.    else
  1403.    {
  1404.       this.zoomifySplash_mc._visible = true;
  1405.    }
  1406. };
  1407. ZoomifyViewerClass.prototype.viewerInitialized = function()
  1408. {
  1409.    var i;
  1410.    if(this.gDoImmediateClipRemoval == false)
  1411.    {
  1412.       i = 0;
  1413.       while(i < this.gInitializeCallback.length)
  1414.       {
  1415.          this.gInitializeCallback[i](this);
  1416.          i++;
  1417.       }
  1418.       i = 0;
  1419.       while(i < this.gStatusCallback.length)
  1420.       {
  1421.          this.gStatusCallback[i]("Image initialized.");
  1422.          i++;
  1423.       }
  1424.    }
  1425.    if(this._preloadTransitions != true || this.gCacheArray.length <= this.gCurrentCacheIndex)
  1426.    {
  1427.       this.zoomifySplash_mc._visible = false;
  1428.    }
  1429.    if(this.gSavedZoomToView == true)
  1430.    {
  1431.       this.gSavedZoomToView = false;
  1432.       var tempEnabled = this.gEnabled;
  1433.       this.setEnabled(true);
  1434.       this.zoomToView(this.gEndZoomX,this.gEndZoomY,this.gEndZoomZoom,this.gZoomDuration,this.gZoomIntervalRate,"","");
  1435.       this.setEnabled(tempEnabled);
  1436.    }
  1437.    else
  1438.    {
  1439.       this.gHaltViewMessages = false;
  1440.    }
  1441. };
  1442. ZoomifyViewerClass.prototype.onUnload = function()
  1443. {
  1444.    this.destroy();
  1445. };
  1446. ZoomifyViewerClass.prototype.destroy = function()
  1447. {
  1448.    if(this.gInitialized == false)
  1449.    {
  1450.       return undefined;
  1451.    }
  1452.    this.gInitialized = false;
  1453.    if(this.gInitialHeaderIntervalID != -1)
  1454.    {
  1455.       clearInterval(this.gInitialHeaderIntervalID);
  1456.       this.gInitialHeaderIntervalID = -1;
  1457.    }
  1458.    this.stopZoomToView();
  1459.    this.removeAllLabels();
  1460.    this.destroyBackground();
  1461.    if(this.gTilesUsedOldTierArray1 != undefined)
  1462.    {
  1463.       this.unloadTilesInArray(this.gTilesUsedOldTierArray1);
  1464.       delete this.gTilesUsedOldTierArray1;
  1465.    }
  1466.    if(this.gTilesUsedOldTierArray2 != undefined)
  1467.    {
  1468.       this.unloadTilesInArray(this.gTilesUsedOldTierArray2);
  1469.       delete this.gTilesUsedOldTierArray2;
  1470.    }
  1471.    if(this.gTilesUsedArray1 != undefined)
  1472.    {
  1473.       this.unloadTilesInArray(this.gTilesUsedArray1);
  1474.       delete this.gTilesUsedArray1;
  1475.    }
  1476.    if(this.gTilesUsedArray2 != undefined)
  1477.    {
  1478.       this.unloadTilesInArray(this.gTilesUsedArray2);
  1479.       delete this.gTilesUsedArray2;
  1480.    }
  1481.    i = 0;
  1482.    while(i < this.gOffsetChunkArray.length)
  1483.    {
  1484.       if(this.gOffsetChunkArray[i] != undefined)
  1485.       {
  1486.          delete this.gOffsetChunkArray[i];
  1487.       }
  1488.       i++;
  1489.    }
  1490.    i = 1;
  1491.    while(i < this.numPremadeLevels)
  1492.    {
  1493.       var movieClipString = "tier" + i + "_mc";
  1494.       var tempTier_mc = eval("this." + movieClipString);
  1495.       if(tempTier_mc != undefined)
  1496.       {
  1497.          tempTier_mc.removeMovieClip();
  1498.          tempTier_mc = undefined;
  1499.       }
  1500.       i++;
  1501.    }
  1502.    this.mask_mc.removeMovieClip();
  1503.    if(this.gPreserveCache == false)
  1504.    {
  1505.       this.emptyCache();
  1506.    }
  1507.    delete this.gTileCountWidth;
  1508.    delete this.gTileCountHeight;
  1509.    delete this.gTierTileCount;
  1510.    delete this.gTierWidth;
  1511.    delete this.gTierHeight;
  1512.    delete this.gTileCacheoffsetIndex;
  1513.    delete this.gTilesUsedArray1;
  1514.    delete this.gTilesUsedArray2;
  1515.    delete this.gTilesUsedOldTierArray1;
  1516.    delete this.gTilesUsedOldTierArray2;
  1517.    delete this.gMetersPerPixel;
  1518. };
  1519. ZoomifyViewerClass.prototype.destroyBackground = function()
  1520. {
  1521.    var tempTile;
  1522.    var rowCounter;
  1523.    var columnCounter;
  1524.    rowCounter = 1;
  1525.    while(rowCounter <= this.getTileCountHeight(this.gBackgroundTier))
  1526.    {
  1527.       columnCounter = 1;
  1528.       while(columnCounter <= this.getTileCountWidth(this.gBackgroundTier))
  1529.       {
  1530.          tileName = this.gBackgroundTier + "-" + rowCounter + "-" + columnCounter;
  1531.          var mcTileString = "this.tier" + this.gBackgroundTier + "_mc" + "." + tileName;
  1532.          tempTile = eval(mcTileString);
  1533.          if(tempTile != undefined)
  1534.          {
  1535.             tempTile._x = this.gOffscreenX;
  1536.             if(movieToAdd.cacheIndex != undefined)
  1537.             {
  1538.                unloadMovie(tempTile);
  1539.             }
  1540.          }
  1541.          columnCounter++;
  1542.       }
  1543.       rowCounter++;
  1544.    }
  1545. };
  1546. ZoomifyViewerClass.prototype.initView = function()
  1547. {
  1548.    this.gCurrentTier = this.gStartTier;
  1549.    this.gCurrentTier_mc = eval("this.tier" + this.gCurrentTier + "_mc");
  1550.    this.gOldTier = this.gStartTier - 1;
  1551.    if(this.gOldTier == this.gBackgroundTier)
  1552.    {
  1553.       this.gOldTier = 1;
  1554.    }
  1555.    this.gCurrentTierOld_mc = eval("this.tier" + this.gOldTier + "_mc");
  1556.    this.gCurrentTierBackground_mc = eval("this.tier" + this.gBackgroundTier + "_mc");
  1557.    this.gRegistrationPointX = 0;
  1558.    this.gRegistrationPointY = 0;
  1559.    this.gCurrentTierBackground_mc._xscale = this.gCurrentTier_mc._xscale / (this.getTierWidth(this.gBackgroundTier) / this.getTierWidth(this.gCurrentTier));
  1560.    this.gCurrentTierBackground_mc._yscale = this.gCurrentTier_mc._yscale / (this.getTierHeight(this.gBackgroundTier) / this.getTierHeight(this.gCurrentTier));
  1561.    this.gLabelTier_mc._xscale = this.gCurrentTierBackground_mc._xscale;
  1562.    this.gLabelTier_mc._yscale = this.gCurrentTierBackground_mc._yscale;
  1563.    var tempEnabled = this.gEnabled;
  1564.    this.setEnabled(true);
  1565.    this.setView(this._initialX,this._initialY,this._initialZoom);
  1566.    this.setEnabled(tempEnabled);
  1567. };
  1568. ZoomifyViewerClass.prototype.setTier = function()
  1569. {
  1570.    var currentTier = this.gTierCount;
  1571.    var currZoom = 1;
  1572.    var tempZoom = this.getZoom() / 100;
  1573.    while(currZoom > tempZoom)
  1574.    {
  1575.       currentTier--;
  1576.       currZoom /= 2;
  1577.    }
  1578.    if(currentTier < this.gTierCount)
  1579.    {
  1580.       currentTier++;
  1581.    }
  1582.    if(currentTier < this.gMinTier)
  1583.    {
  1584.       currentTier = this.gMinTier;
  1585.    }
  1586.    var tierWidth = this.getTierWidth(this.gTierCount);
  1587.    var tierHeight = this.getTierHeight(this.gTierCount);
  1588.    tierWidth = this.getTierWidth(currentTier);
  1589.    tierHeight = this.getTierHeight(currentTier);
  1590.    if(currentTier != this.gCurrentTier)
  1591.    {
  1592.       if(this.gCurrentTier > this.gBackgroundTier)
  1593.       {
  1594.          this.gCurrentTierOld_mc = this.gCurrentTier_mc;
  1595.       }
  1596.       this.gCurrentTier_mc = eval("this.tier" + currentTier + "_mc");
  1597.       this.gCurrentTier_mc._x = this.gRegistrationPointX;
  1598.       this.gCurrentTier_mc._y = this.gRegistrationPointY;
  1599.       this.gCurrentTier_mc._rotation = this.gCurrentTierBackground_mc._rotation;
  1600.       this.gCurrentTier_mc._xscale = this.gCurrentTierBackground_mc._xscale / (this.getTierWidth(currentTier) / this.getTierWidth(this.gBackgroundTier));
  1601.       this.gCurrentTier_mc._yscale = this.gCurrentTierBackground_mc._yscale / (this.getTierHeight(currentTier) / this.getTierHeight(this.gBackgroundTier));
  1602.       if(this.gOldTier > this.gBackgroundTier)
  1603.       {
  1604.          this.unloadTilesInArray(this.gTilesUsedOldTierArray1,false);
  1605.          this.unloadTilesInArray(this.gTilesUsedOldTierArray2,false);
  1606.       }
  1607.       delete this.gTilesUsedOldTierArray1;
  1608.       delete this.gTilesUsedOldTierArray2;
  1609.       this.gOldTier = this.gCurrentTier;
  1610.       this.gCurrentTier = currentTier;
  1611.       if(this.gOldTier < this.gCurrentTier)
  1612.       {
  1613.          var tempArray1 = new Array();
  1614.          var tempArray2 = new Array();
  1615.          this.gTilesUsedOldTierArray1 = tempArray1.concat(this.gTilesUsedArray1);
  1616.          this.gTilesUsedOldTierArray2 = tempArray2.concat(this.gTilesUsedArray2);
  1617.          delete tempArray1;
  1618.          delete tempArray2;
  1619.       }
  1620.       else
  1621.       {
  1622.          this.gTilesUsedOldTierArray1 = new Array();
  1623.          this.gTilesUsedOldTierArray2 = new Array();
  1624.          if(this.gOldTier > this.gBackgroundTier)
  1625.          {
  1626.             this.unloadTilesInArray(this.gTilesUsedArray1,false);
  1627.             this.unloadTilesInArray(this.gTilesUsedArray2,false);
  1628.          }
  1629.          this.gOldTier = this.gCurrentTier - 1;
  1630.          if(this.gOldTier <= 0)
  1631.          {
  1632.             this.gOldTier = 1;
  1633.          }
  1634.          this.gCurrentTierOld_mc = eval("this.tier" + this.gOldTier + "_mc");
  1635.          this.gCurrentTierOld_mc._x = this.gRegistrationPointX;
  1636.          this.gCurrentTierOld_mc._y = this.gRegistrationPointY;
  1637.          this.gCurrentTierOld_mc._xscale = this.gCurrentTierBackground_mc._xscale / (this.getTierWidth(this.gOldTier) / this.getTierWidth(this.gBackgroundTier));
  1638.          this.gCurrentTierOld_mc._yscale = this.gCurrentTierBackground_mc._yscale / (this.getTierHeight(this.gOldTier) / this.getTierHeight(this.gBackgroundTier));
  1639.       }
  1640.       delete this.gTilesUsedArray1;
  1641.       delete this.gTilesUsedArray2;
  1642.       this.gTilesUsedArray1 = new Array();
  1643.       this.gTilesUsedArray2 = new Array();
  1644.       this.gCurrentTier_mc._visible = true;
  1645.       this.gCurrentTierOld_mc._visible = true;
  1646.    }
  1647. };
  1648. ZoomifyViewerClass.prototype.unloadTilesInArray = function(tileArray, checkVisible)
  1649. {
  1650.    var i;
  1651.    i = 0;
  1652.    while(i < tileArray.length)
  1653.    {
  1654.       var tempTile = eval(tileArray[i]);
  1655.       if(tempTile != undefined && (checkVisible == false || tempTile._visible == false && checkVisible == true))
  1656.       {
  1657.          tempTile._x = this.gOffscreenX;
  1658.          if(movieToAdd.cacheIndex != undefined)
  1659.          {
  1660.             unloadMovie(tempTile);
  1661.          }
  1662.       }
  1663.       i++;
  1664.    }
  1665. };
  1666. ZoomifyViewerClass.prototype.setTileArrayVisibility = function(tileArray, visibilityFlag)
  1667. {
  1668.    var i;
  1669.    i = 0;
  1670.    while(i < tileArray.length)
  1671.    {
  1672.       var tempTile = eval(tileArray[i]);
  1673.       tempTile._visible = visibilityFlag;
  1674.       i++;
  1675.    }
  1676. };
  1677. ZoomifyViewerClass.prototype.fillView = function()
  1678. {
  1679.    var savedRotation = this._rotation;
  1680.    this._rotation = 0;
  1681.    this.fillViewWithParams(this.gBackgroundTier,this.gCurrentTierBackground_mc,"");
  1682.    var currentArray = this.gCurrentTierArray;
  1683.    var oldArray = 1;
  1684.    if(currentArray == 1)
  1685.    {
  1686.       oldArray = 2;
  1687.    }
  1688.    this.setTileArrayVisibility(eval("this.gTilesUsedArray" + oldArray),false);
  1689.    if(this.gCurrentTier > this.gBackgroundTier)
  1690.    {
  1691.       this.fillViewWithParams(this.gCurrentTier,this.gCurrentTier_mc,"this.gTilesUsedArray" + currentArray);
  1692.    }
  1693.    if(this.gCurrentTier != this.gBackgroundTier)
  1694.    {
  1695.       this.unloadTilesInArray(eval("this.gTilesUsedArray" + oldArray),true);
  1696.    }
  1697.    if(this.gOldTier < this.gCurrentTier && this.gOldTier > 0)
  1698.    {
  1699.       this.setTileArrayVisibility(eval("this.gTilesUsedOldTierArray" + oldArray),false);
  1700.       if(this.gOldTier > this.gBackgroundTier)
  1701.       {
  1702.          this.fillViewWithParams(this.gOldTier,this.gCurrentTierOld_mc,"this.gTilesUsedOldTierArray" + currentArray);
  1703.       }
  1704.       if(this.gOldTier != this.gBackgroundTier)
  1705.       {
  1706.          this.unloadTilesInArray(eval("this.gTilesUsedOldTierArray" + oldArray),true);
  1707.       }
  1708.    }
  1709.    if(currentArray == 1)
  1710.    {
  1711.       delete this.gTilesUsedOldTierArray2;
  1712.       delete this.gTilesUsedArray2;
  1713.       this.gTilesUsedOldTierArray2 = new Array();
  1714.       this.gTilesUsedArray2 = new Array();
  1715.    }
  1716.    else
  1717.    {
  1718.       delete this.gTilesUsedOldTierArray1;
  1719.       delete this.gTilesUsedArray1;
  1720.       this.gTilesUsedOldTierArray1 = new Array();
  1721.       this.gTilesUsedArray1 = new Array();
  1722.    }
  1723.    this.gCurrentTierArray = oldArray;
  1724.    i = 0;
  1725.    while(i < this.gViewCallback.length)
  1726.    {
  1727.       this.gViewCallback[i](this,this.getX(),this.getY(),this.getZoom());
  1728.       i++;
  1729.    }
  1730.    i = 0;
  1731.    while(i < this.gRectCallback.length)
  1732.    {
  1733.       this.gRectCallback[i](this,this.getWindowLeft(),this.getWindowTop(),this.getWindowRight(),this.getWindowBottom());
  1734.       i++;
  1735.    }
  1736.    this.sendMessage("setView:" + this.getX() + ":" + this.getY() + ":" + this.getZoom());
  1737.    this._rotation = savedRotation;
  1738. };
  1739. ZoomifyViewerClass.prototype.fillViewWithParams = function(tier, mClip, newTierArrayName)
  1740. {
  1741.    var newTierArray;
  1742.    if(newTierArrayName != "")
  1743.    {
  1744.       newTierArray = eval(newTierArrayName);
  1745.    }
  1746.    var i;
  1747.    var tempTile;
  1748.    var tileName = "";
  1749.    var tileLevel = 0;
  1750.    var rowCounter = 0;
  1751.    var columnCounter = 0;
  1752.    var tierWidth = this.getTierWidth(tier);
  1753.    var tierHeight = this.getTierHeight(tier);
  1754.    var screenRectLeft = (- this.gViewWidth) / 2;
  1755.    var screenRectRight = this.gViewWidth / 2;
  1756.    var screenRectTop = (- this.gViewHeight) / 2;
  1757.    var screenRectBottom = this.gViewHeight / 2;
  1758.    var scale = mClip._xscale / 100;
  1759.    var scaledTileSize = scale * this.gTileSize;
  1760.    var imageRectLeft = this.gPanPositionX * tierWidth - tierWidth / 2;
  1761.    var imageRectTop = this.gPanPositionY * tierHeight - tierHeight / 2;
  1762.    var imageRectRight = this.gPanPositionX * tierWidth + tierWidth / 2;
  1763.    var imageRectBottom = this.gPanPositionY * tierHeight + tierHeight / 2;
  1764.    var scaledCenterX = tierWidth * scale / 2 - this.gPanPositionX * tierWidth * scale;
  1765.    var scaledCenterY = tierHeight * scale / 2 - this.gPanPositionY * tierHeight * scale;
  1766.    var scaledTop = scaledCenterY + screenRectTop;
  1767.    var scaledLeft = scaledCenterX + screenRectLeft;
  1768.    var scaledTempBottom = scaledCenterY + screenRectBottom;
  1769.    var scaledTempRight = scaledCenterX + screenRectRight;
  1770.    this.gScaledWindowTop = scaledTop / (scale * tierHeight);
  1771.    this.gScaledWindowBottom = scaledTempBottom / (scale * tierHeight);
  1772.    this.gScaledWindowLeft = scaledLeft / (scale * tierWidth);
  1773.    this.gScaledWindowRight = scaledTempRight / (scale * tierWidth);
  1774.    var leftViewColumn = Math.floor(scaledLeft / scaledTileSize) + 1;
  1775.    var topViewRow = Math.floor(scaledTop / scaledTileSize) + 1;
  1776.    var rightViewColumn = Math.floor(scaledTempRight / scaledTileSize) + 1;
  1777.    var bottomViewRow = Math.floor(scaledTempBottom / scaledTileSize) + 1;
  1778.    if(leftViewColumn < 1 || tier == this.gBackgroundTier)
  1779.    {
  1780.       leftViewColumn = 1;
  1781.    }
  1782.    if(topViewRow < 1 || tier == this.gBackgroundTier)
  1783.    {
  1784.       topViewRow = 1;
  1785.    }
  1786.    if(rightViewColumn > this.getTileCountWidth(tier) || tier == this.gBackgroundTier)
  1787.    {
  1788.       rightViewColumn = this.getTileCountWidth(tier);
  1789.    }
  1790.    if(bottomViewRow > this.getTileCountHeight(tier) || tier == this.gBackgroundTier)
  1791.    {
  1792.       bottomViewRow = this.getTileCountHeight(tier);
  1793.    }
  1794.    var viewColumns = rightViewColumn - leftViewColumn + 1;
  1795.    var viewRows = bottomViewRow - topViewRow + 1;
  1796.    rowCounter = topViewRow;
  1797.    while(rowCounter <= bottomViewRow)
  1798.    {
  1799.       columnCounter = leftViewColumn;
  1800.       while(columnCounter <= rightViewColumn)
  1801.       {
  1802.          var xPosition = (columnCounter - 1) * this.gTileSize + imageRectLeft;
  1803.          var yPosition = (rowCounter - 1) * this.gTileSize + imageRectTop;
  1804.          tileName = tier + "-" + rowCounter + "-" + columnCounter;
  1805.          tileLevel = (columnCounter - 1 + (rowCounter - 1) * viewColumns) % 65000 + 10;
  1806.          var mcTileString = "this.tier" + tier + "_mc" + "." + tileName;
  1807.          mcTile = eval(mcTileString);
  1808.          tileSource = this.getTileURL(tier,columnCounter,rowCounter);
  1809.          if(tileSource != "missing")
  1810.          {
  1811.             if(this.gInTransition == false)
  1812.             {
  1813.                if(mcTile == undefined)
  1814.                {
  1815.                   mClip.createEmptyMovieClip(tileName,tileLevel);
  1816.                   mcTile = eval(mcTileString);
  1817.                   mcTile._x = this.gOffscreenX;
  1818.                }
  1819.                if(mcTile._x == this.gOffscreenX && tileSource != "missing")
  1820.                {
  1821.                   loadMovie(tileSource,mcTile);
  1822.                   this.addTileToQueue(mcTile);
  1823.                }
  1824.             }
  1825.             if(mcTile != undefined)
  1826.             {
  1827.                mcTile._x = xPosition;
  1828.                mcTile._y = yPosition;
  1829.                mcTile._visible = true;
  1830.             }
  1831.          }
  1832.          if(tier != this.gBackgroundTier && mcTile != undefined)
  1833.          {
  1834.             newTierArray[newTierArray.length] = mcTileString;
  1835.          }
  1836.          columnCounter++;
  1837.       }
  1838.       rowCounter++;
  1839.    }
  1840.    if(this.zoomifySplash_mc._visible == false || this.gCurrentCacheIndex == 0)
  1841.    {
  1842.       mClip._visible = true;
  1843.    }
  1844.    else
  1845.    {
  1846.       mClip._visible = false;
  1847.    }
  1848.    if(tier == this.gBackgroundTier)
  1849.    {
  1850.       this.gLabelTier_mc.labels_mc._x = imageRectLeft;
  1851.       this.gLabelTier_mc.labels_mc._y = imageRectTop;
  1852.    }
  1853. };
  1854. ZoomifyViewerClass.prototype.checkFormatCallback = function(callbackType, tier, x, y)
  1855. {
  1856.    if(this.gFormatCallback.length == 0)
  1857.    {
  1858.       return "";
  1859.    }
  1860.    var imageExtension = this._imagePath.substring(this._imagePath.length - 3,this._imagePath.length).toLowerCase();
  1861.    var usedCallback = false;
  1862.    var i;
  1863.    i = 0;
  1864.    while(i < this.gFormatCallback.length)
  1865.    {
  1866.       if(imageExtension == this.gFormatCallback[i].extension)
  1867.       {
  1868.          return this.gFormatCallback[i].callback(this,callbackType,tier,x,y);
  1869.       }
  1870.       i++;
  1871.    }
  1872.    return "";
  1873. };
  1874. ZoomifyViewerClass.prototype.getHeader = function()
  1875. {
  1876.    if(this.gInitialHeaderIntervalID != -1)
  1877.    {
  1878.       clearInterval(this.gInitialHeaderIntervalID);
  1879.       this.gInitialHeaderIntervalID = -1;
  1880.    }
  1881.    if(this.checkFormatCallback("Header",0,0,0) == "")
  1882.    {
  1883.       this.getImagePropertiesFile();
  1884.    }
  1885. };
  1886. ZoomifyViewerClass.prototype.getTileURL = function(tier, x, y)
  1887. {
  1888.    var _loc2_ = this.checkFormatCallback("TileURL",tier - 1,x - 1,y - 1);
  1889.    if(_loc2_ == "")
  1890.    {
  1891.       _loc2_ = this.getFolderTileURL(tier - 1,x - 1,y - 1);
  1892.    }
  1893.    return _loc2_;
  1894. };
  1895. ZoomifyViewerClass.prototype.buildPyramid = function(imageWidth, imageHeight, pyramidType, tileSize, minTier)
  1896. {
  1897.    this.gImageHeight = imageHeight;
  1898.    this.gImageWidth = imageWidth;
  1899.    this.gTileSize = tileSize;
  1900.    this.gPyramidType = pyramidType;
  1901.    this.gMinTier = minTier;
  1902.    var _loc2_ = this.gImageWidth;
  1903.    var _loc3_ = this.gImageHeight;
  1904.    this.gTierCount = 1;
  1905.    var _loc5_ = 2;
  1906.    while(_loc2_ > this.gTileSize || _loc3_ > this.gTileSize)
  1907.    {
  1908.       if(pyramidType == "Div2")
  1909.       {
  1910.          _loc2_ = Math.floor(_loc2_ / 2);
  1911.          _loc3_ = Math.floor(_loc3_ / 2);
  1912.       }
  1913.       else if(pyramidType == "Plus1Div2")
  1914.       {
  1915.          _loc2_ = Math.floor((_loc2_ + 1) / 2);
  1916.          _loc3_ = Math.floor((_loc3_ + 1) / 2);
  1917.       }
  1918.       else
  1919.       {
  1920.          _loc2_ = Math.floor(this.gImageWidth / _loc5_);
  1921.          _loc3_ = Math.floor(this.gImageHeight / _loc5_);
  1922.          _loc5_ *= 2;
  1923.          if(_loc2_ % 2)
  1924.          {
  1925.             _loc2_ = _loc2_ + 1;
  1926.          }
  1927.          if(_loc3_ % 2)
  1928.          {
  1929.             _loc3_ = _loc3_ + 1;
  1930.          }
  1931.       }
  1932.       this.gTierCount = this.gTierCount + 1;
  1933.    }
  1934.    this.gStartTier = minTier;
  1935.    this.gCurrentTier = minTier;
  1936.    this.gBackgroundTier = minTier;
  1937.    _loc2_ = this.gImageWidth;
  1938.    _loc3_ = this.gImageHeight;
  1939.    var _loc4_ = undefined;
  1940.    _loc5_ = 2;
  1941.    _loc4_ = this.gTierCount - 1;
  1942.    while(_loc4_ >= 0)
  1943.    {
  1944.       this.gTileCountWidth[_loc4_] = Math.floor(_loc2_ / this.gTileSize);
  1945.       if(_loc2_ % this.gTileSize)
  1946.       {
  1947.          this.gTileCountWidth[_loc4_] = this.gTileCountWidth[_loc4_] + 1;
  1948.       }
  1949.       this.gTileCountHeight[_loc4_] = Math.floor(_loc3_ / this.gTileSize);
  1950.       if(_loc3_ % this.gTileSize)
  1951.       {
  1952.          this.gTileCountHeight[_loc4_] = this.gTileCountHeight[_loc4_] + 1;
  1953.       }
  1954.       this.gTierTileCount[_loc4_] = this.gTileCountWidth[_loc4_] * this.gTileCountHeight[_loc4_];
  1955.       this.gTierWidth[_loc4_] = _loc2_;
  1956.       this.gTierHeight[_loc4_] = _loc3_;
  1957.       if(pyramidType == "Div2")
  1958.       {
  1959.          _loc2_ = Math.floor(_loc2_ / 2);
  1960.          _loc3_ = Math.floor(_loc3_ / 2);
  1961.       }
  1962.       else if(pyramidType == "Plus1Div2")
  1963.       {
  1964.          _loc2_ = Math.floor((_loc2_ + 1) / 2);
  1965.          _loc3_ = Math.floor((_loc3_ + 1) / 2);
  1966.       }
  1967.       else
  1968.       {
  1969.          _loc2_ = Math.floor(this.gImageWidth / _loc5_);
  1970.          _loc3_ = Math.floor(this.gImageHeight / _loc5_);
  1971.          _loc5_ *= 2;
  1972.          if(_loc2_ % 2)
  1973.          {
  1974.             _loc2_ = _loc2_ + 1;
  1975.          }
  1976.          if(_loc3_ % 2)
  1977.          {
  1978.             _loc3_ = _loc3_ + 1;
  1979.          }
  1980.       }
  1981.       _loc4_ = _loc4_ - 1;
  1982.    }
  1983.    this.gViewerState = 3;
  1984.    this.gInitialized = true;
  1985.    this.initView();
  1986.    this.updateView();
  1987.    updateAfterEvent();
  1988.    this.viewerInitialized();
  1989. };
  1990. ZoomifyViewerClass.prototype.getInitializationData = function(initObject)
  1991. {
  1992.    initObject.gImageHeight = this.gImageHeight;
  1993.    initObject.gImageWidth = this.gImageWidth;
  1994.    initObject.gTileSize = this.gTileSize;
  1995.    initObject.gPyramidType = this.gPyramidType;
  1996.    initObject.gMinTier = this.gMinTier;
  1997. };
  1998. ZoomifyViewerClass.prototype.getImagePropertiesFile = function()
  1999. {
  2000.    var _loc10_ = this._imagePath.length;
  2001.    if(this._imagePath.charAt(_loc10_ - 1) != "/")
  2002.    {
  2003.       this._imagePath += "/";
  2004.    }
  2005.    if(this._imagePath.substring(0,6) == "swf://")
  2006.    {
  2007.       var _loc5_ = _root._url;
  2008.       var _loc3_ = undefined;
  2009.       var _loc6_ = _loc5_.length;
  2010.       _loc3_ = _loc6_ - 1;
  2011.       while(_loc3_ > 0)
  2012.       {
  2013.          if(_loc5_.charAt(_loc3_) == "/")
  2014.          {
  2015.             var _loc4_ = this._imagePath.substring(6,this._imagePath.length);
  2016.             this._imagePath = _loc5_.subString(0,_loc3_ + 1) + _loc4_;
  2017.             break;
  2018.          }
  2019.          _loc3_ = _loc3_ - 1;
  2020.       }
  2021.    }
  2022.    var _loc7_ = new XML();
  2023.    _loc7_.ignoreWhite = true;
  2024.    _loc7_.owner = this;
  2025.    _loc7_.onData = this.onImagePropertiesData;
  2026.    var _loc8_ = "";
  2027.    if(this._byteHandlerURL != "" && this._byteHandlerURL != "Leave blank unless publishing a PFF, JP2, or MrSid file")
  2028.    {
  2029.       _loc8_ = this._byteHandlerURL;
  2030.    }
  2031.    var _loc9_ = _loc8_ + this._imagePath + "ImageProperties.xml";
  2032.    _loc7_.load(_loc9_);
  2033. };
  2034. ZoomifyViewerClass.prototype.onImagePropertiesData = function(theData)
  2035. {
  2036.    var _loc8_ = new XML(theData);
  2037.    var _loc3_ = _loc8_.childNodes;
  2038.    var _loc2_ = undefined;
  2039.    var _loc4_ = 0;
  2040.    var _loc5_ = 0;
  2041.    var _loc6_ = undefined;
  2042.    var _loc7_ = 1;
  2043.    _loc2_ = 0;
  2044.    while(_loc2_ < _loc3_.length)
  2045.    {
  2046.       if(_loc3_[_loc2_].nodeName == "IMAGE_PROPERTIES")
  2047.       {
  2048.          _loc4_ = parseInt(_loc3_[_loc2_].attributes.WIDTH);
  2049.          _loc5_ = parseInt(_loc3_[_loc2_].attributes.HEIGHT);
  2050.          _loc6_ = parseInt(_loc3_[_loc2_].attributes.TILESIZE);
  2051.       }
  2052.       _loc2_ = _loc2_ + 1;
  2053.    }
  2054.    if(_loc4_ == 0 || _loc5_ == 0)
  2055.    {
  2056.       return undefined;
  2057.    }
  2058.    this.owner.buildPyramid(_loc4_,_loc5_,"Div2",_loc6_,_loc7_);
  2059.    this.owner = undefined;
  2060.    false;
  2061. };
  2062. ZoomifyViewerClass.prototype.getFolderTileURL = function(tier, x, y)
  2063. {
  2064.    if(this._imagePath.charAt(this._imagePath.length - 1) != "/")
  2065.    {
  2066.       this._imagePath += "/";
  2067.    }
  2068.    var _loc3_ = parseFloat(y * this.gTileCountWidth[tier] + x);
  2069.    var _loc2_ = undefined;
  2070.    _loc2_ = 0;
  2071.    while(_loc2_ < tier)
  2072.    {
  2073.       _loc3_ += this.gTierTileCount[_loc2_];
  2074.       _loc2_ = _loc2_ + 1;
  2075.    }
  2076.    var _loc8_ = Math.floor(_loc3_ / 256);
  2077.    var _loc5_ = "";
  2078.    if(this._byteHandlerURL != "" && this._byteHandlerURL != "Leave blank unless publishing a PFF, JP2, or MrSid file")
  2079.    {
  2080.       _loc5_ = this._byteHandlerURL;
  2081.    }
  2082.    var _loc7_ = _loc5_ + this._imagePath;
  2083.    var _loc6_ = _loc7_ + "TileGroup" + _loc8_ + "/" + tier + "-" + x + "-" + y + ".jpg";
  2084.    return _loc6_;
  2085. };
  2086. ZoomifyViewerClass.prototype.addTileToQueue = function(movieToAdd)
  2087. {
  2088.    this.gTileQueue[this.gTileQueue.length] = movieToAdd;
  2089.    this.gMaxTileQueueLength = this.gMaxTileQueueLength + 1;
  2090.    if(this.gLastTileTime == -1)
  2091.    {
  2092.       this.gLastTileTime = getTimer();
  2093.    }
  2094.    if(this.gTileQueueIntervalID == -1)
  2095.    {
  2096.       this.gTileQueueIntervalID = setInterval(this,"checkTileQueue",30);
  2097.    }
  2098. };
  2099. ZoomifyViewerClass.prototype.checkTileQueue = function()
  2100. {
  2101.    var i;
  2102.    i = this.gTileQueue.length - 1;
  2103.    while(i >= 0)
  2104.    {
  2105.       var totalBytes = this.gTileQueue[i].getBytesTotal();
  2106.       var bytesLoaded = this.gTileQueue[i].getBytesLoaded();
  2107.       if(!(totalBytes > 0 && bytesLoaded >= totalBytes))
  2108.       {
  2109.          if(getTimer() - this.gLastTileTime > 5000)
  2110.          {
  2111.             this.gTileQueue[i]._x = this.gOffscreenX;
  2112.             this.gTileQueue.splice(i,1);
  2113.             this.gLastTileTime = -1;
  2114.             this.updateView();
  2115.             return true;
  2116.          }
  2117.          break;
  2118.       }
  2119.       this.gTileQueue.splice(i,1);
  2120.       i--;
  2121.    }
  2122.    if(this.gTileQueue.length > 0)
  2123.    {
  2124.       i = 0;
  2125.       while(i < this.gDownloadsCompleteCallback.length)
  2126.       {
  2127.          var percentDone = Math.round(100 * (this.gMaxTileQueueLength - this.gTileQueue.length) / this.gMaxTileQueueLength);
  2128.          this.gDownloadsCompleteCallback[i](this,percentDone);
  2129.          i++;
  2130.       }
  2131.       return true;
  2132.    }
  2133.    delete this.gTileQueue;
  2134.    this.gTileQueue = new Array();
  2135.    clearInterval(this.gTileQueueIntervalID);
  2136.    this.gTileQueueIntervalID = -1;
  2137.    this.gMaxTileQueueLength = 0;
  2138.    if(this.gCacheArray.length > this.gCurrentCacheIndex)
  2139.    {
  2140.       this.cacheNextView();
  2141.    }
  2142.    i = 0;
  2143.    while(i < this.gDownloadsCompleteCallback.length)
  2144.    {
  2145.       this.gDownloadsCompleteCallback[i](this,100);
  2146.       i++;
  2147.    }
  2148.    return false;
  2149. };
  2150. ZoomifyViewerClass.prototype.cacheViews = function(viewsArray, callbackString)
  2151. {
  2152.    this.gCacheViewsCallback = callbackString;
  2153.    this.gCacheArray = this.gCacheArray.concat(viewsArray);
  2154.    if(this.gTileQueueIntervalID == -1)
  2155.    {
  2156.       this.checkTileQueue();
  2157.    }
  2158. };
  2159. ZoomifyViewerClass.prototype.removeCachedView = function(name)
  2160. {
  2161.    var _loc2_ = undefined;
  2162.    _loc2_ = 0;
  2163.    if(_loc2_ < this.gCacheArray.length)
  2164.    {
  2165.       this.gCacheArray[_loc2_].clip.destroy();
  2166.       this.gCacheArray[_loc2_].clip.removeMovieClip();
  2167.       this.gCacheArray.splice(_loc2_,1);
  2168.       if(this.gCurrentCacheIndex > _loc2_)
  2169.       {
  2170.          this.gCurrentCacheIndex = this.gCurrentCacheIndex - 1;
  2171.       }
  2172.       return undefined;
  2173.    }
  2174. };
  2175. ZoomifyViewerClass.prototype.emptyCache = function()
  2176. {
  2177.    if(this.gTileQueueIntervalID != -1)
  2178.    {
  2179.       delete this.gTileQueue;
  2180.       clearInterval(this.gTileQueueIntervalID);
  2181.       this.gTileQueueIntervalID = -1;
  2182.    }
  2183.    if(this.gCacheViewsIntervalID != -1)
  2184.    {
  2185.       clearInterval(this.gCacheViewsIntervalID);
  2186.    }
  2187.    this.gCacheViewsIntervalID = -1;
  2188.    i = 0;
  2189.    while(i < this.gCacheArray.length)
  2190.    {
  2191.       this.gCacheArray[i].clip.destroy();
  2192.       this.gCacheArray[i].clip.removeMovieClip();
  2193.       delete this.gCacheArray[i];
  2194.       i++;
  2195.    }
  2196.    delete this.gCacheArray;
  2197.    this.gCacheArray = new Array();
  2198.    i = 0;
  2199.    while(i < this.gNumTransitions)
  2200.    {
  2201.       delete this.gTransitionList[i];
  2202.       i++;
  2203.    }
  2204.    delete this.gTransitionList;
  2205.    this.gTransitionList = new Array();
  2206.    this.unloadTilesInArray(this.gTileCache,false);
  2207.    delete this.gTileCache;
  2208.    this.gTileCache = new Array();
  2209.    this.gCurrentCacheIndex = 0;
  2210. };
  2211. ZoomifyViewerClass.prototype.getCachedView = function(name)
  2212. {
  2213.    var _loc2_ = undefined;
  2214.    _loc2_ = 0;
  2215.    while(_loc2_ < this.gCacheArray.length)
  2216.    {
  2217.       if(this.gCacheArray[_loc2_].name == name)
  2218.       {
  2219.          return this.gCacheArray[_loc2_];
  2220.       }
  2221.       _loc2_ = _loc2_ + 1;
  2222.    }
  2223.    return null;
  2224. };
  2225. ZoomifyViewerClass.prototype.cacheNextView = function()
  2226. {
  2227.    if(this.gCacheViewsIntervalID != -1 || this.gTileQueue.length > 0 || this.gTileQueueIntervalID != -1 || this.gCurrentCacheIndex > 0 && this.gCacheArray[this.gCurrentCacheIndex - 1].intervalID != -1)
  2228.    {
  2229.       return undefined;
  2230.    }
  2231.    var clipName = "ZoomifyTemporaryClip" + this.gCurrentCacheIndex;
  2232.    this.attachMovie("ZoomifyViewerSymbol",clipName,30000 + this.gCurrentCacheIndex);
  2233.    this.gCacheArray[this.gCurrentCacheIndex].clip = eval("this." + clipName);
  2234.    this.gCacheArray[this.gCurrentCacheIndex].clip._x = this.gOffscreenX;
  2235.    this.gCacheArray[this.gCurrentCacheIndex].intervalID = 5;
  2236.    this.gCacheViewsIntervalID = setInterval(this,"cacheViewDelay",10);
  2237. };
  2238. ZoomifyViewerClass.prototype.offscreenMouseEvent = function(theInstance, theEvent)
  2239. {
  2240.    i = 0;
  2241.    while(i < this.gMouseCallback.length)
  2242.    {
  2243.       this.gMouseCallback[i](this,theEvent);
  2244.       i++;
  2245.    }
  2246. };
  2247. ZoomifyViewerClass.prototype.cacheViewDelay = function()
  2248. {
  2249.    if(this.gCacheViewsIntervalID != -1)
  2250.    {
  2251.       clearInterval(this.gCacheViewsIntervalID);
  2252.       this.gCacheViewsIntervalID = -1;
  2253.    }
  2254.    this.gCacheArray[this.gCurrentCacheIndex].clip._x = this.gOffscreenX;
  2255.    var _loc2_ = targetPath(this) + ".viewCached";
  2256.    this.gCacheArray[this.gCurrentCacheIndex].intervalID = this.gCacheArray[this.gCurrentCacheIndex].clip.registerCallback("DownloadComplete",_loc2_);
  2257.    this.gCacheArray[this.gCurrentCacheIndex].clip._initialX = this.gCacheArray[this.gCurrentCacheIndex].x;
  2258.    this.gCacheArray[this.gCurrentCacheIndex].clip._initialY = this.gCacheArray[this.gCurrentCacheIndex].y;
  2259.    this.gCacheArray[this.gCurrentCacheIndex].clip._initialZoom = this.gCacheArray[this.gCurrentCacheIndex].zoom;
  2260.    this.gCacheArray[this.gCurrentCacheIndex].clip._showSplash = false;
  2261.    this.gCacheArray[this.gCurrentCacheIndex].clip._focus = false;
  2262.    this.gCacheArray[this.gCurrentCacheIndex].clip._visible = false;
  2263.    this.gCacheArray[this.gCurrentCacheIndex].clip._minZoom = -1;
  2264.    this.gCacheArray[this.gCurrentCacheIndex].clip._maxZoom = 200;
  2265.    this.gCacheArray[this.gCurrentCacheIndex].clip.setSize(this.gViewWidth,this.gViewHeight);
  2266.    this.gCacheArray[this.gCurrentCacheIndex].clip.setImagePath(this.gCacheArray[this.gCurrentCacheIndex].imagePath);
  2267.    this.gCacheArray[this.gCurrentCacheIndex].clip.setByteHandlerURL(this._byteHandlerURL);
  2268.    this.gCacheArray[this.gCurrentCacheIndex].clip.setMapFilePath(this._mapFilePath);
  2269.    this.gCacheArray[this.gCurrentCacheIndex].clip.setEnabled(false);
  2270.    this.gCacheArray[this.gCurrentCacheIndex].clip.registerCallback("Mouse",targetPath(this) + ".offscreenMouseEvent");
  2271.    this.gCacheArray[this.gCurrentCacheIndex].clip.updateView();
  2272.    this.gCurrentCacheIndex = this.gCurrentCacheIndex + 1;
  2273. };
  2274. ZoomifyViewerClass.prototype.viewCached = function(movieClipInstance, percentComplete)
  2275. {
  2276.    if(this.gCurrentCacheIndex < this.gCacheArray.length || percentComplete < 100)
  2277.    {
  2278.       var _loc3_ = percentComplete / this.gCacheArray.length;
  2279.       this.cacheViewsComplete(Math.round(_loc3_ + 100 * (this.gCurrentCacheIndex - 1) / this.gCacheArray.length));
  2280.       if(percentComplete == 100)
  2281.       {
  2282.          this.gCacheArray[this.gCurrentCacheIndex - 1].clip.unregisterCallback("DownloadComplete",this.gCacheArray[this.gCurrentCacheIndex - 1].intervalID);
  2283.          this.gCacheArray[this.gCurrentCacheIndex - 1].intervalID = -1;
  2284.          this.cacheNextView();
  2285.       }
  2286.    }
  2287.    else
  2288.    {
  2289.       this.gCacheArray[this.gCurrentCacheIndex - 1].clip.unregisterCallback("DownloadComplete",this.gCacheArray[this.gCurrentCacheIndex - 1].intervalID);
  2290.       this.gCacheArray[this.gCurrentCacheIndex - 1].intervalID = -1;
  2291.       this.cacheViewsComplete(100);
  2292.    }
  2293. };
  2294. ZoomifyViewerClass.prototype.cacheViewsComplete = function(percentComplete)
  2295. {
  2296.    if(this.gCacheViewsCallback != "")
  2297.    {
  2298.       this.gCacheViewsCallback(this,percentComplete);
  2299.    }
  2300. };
  2301. ZoomifyViewerClass.prototype.addTransition = function(transitionObject)
  2302. {
  2303.    this.gTransitionList.push(transitionObject);
  2304.    this.gNumTransitions = this.gNumTransitions + 1;
  2305. };
  2306. ZoomifyViewerClass.prototype.removeFromTransitionList = function(name)
  2307. {
  2308.    var _loc2_ = undefined;
  2309.    _loc2_ = 0;
  2310.    while(_loc2_ < this.gNumTransitions)
  2311.    {
  2312.       if(this.gTransitionList[_loc2_].name == name)
  2313.       {
  2314.          this.gTransitionList.splice(_loc2_,1);
  2315.          return true;
  2316.       }
  2317.       _loc2_ = _loc2_ + 1;
  2318.    }
  2319.    return false;
  2320. };
  2321. ZoomifyViewerClass.prototype.getTransitionByName = function(name)
  2322. {
  2323.    var _loc2_ = undefined;
  2324.    _loc2_ = 0;
  2325.    while(_loc2_ < this.gNumTransitions)
  2326.    {
  2327.       if(this.gTransitionList[_loc2_].name == name)
  2328.       {
  2329.          return this.gTransitionList[_loc2_];
  2330.       }
  2331.       _loc2_ = _loc2_ + 1;
  2332.    }
  2333.    return null;
  2334. };
  2335. ZoomifyViewerClass.prototype.doTransitionByName = function(name)
  2336. {
  2337.    var _loc2_ = undefined;
  2338.    _loc2_ = 0;
  2339.    while(_loc2_ < this.gNumTransitions)
  2340.    {
  2341.       if(this.gTransitionList[_loc2_].name == name)
  2342.       {
  2343.          return this.doTransition(this.gTransitionList[_loc2_]);
  2344.       }
  2345.       _loc2_ = _loc2_ + 1;
  2346.    }
  2347.    return false;
  2348. };
  2349. ZoomifyViewerClass.prototype.doTransition = function(transitionObject)
  2350. {
  2351.    if(this.gInitialized == false)
  2352.    {
  2353.       return false;
  2354.    }
  2355.    if(this.gInTransition == true)
  2356.    {
  2357.       if(!(transitionObject.imageEffectDuration == 0 && (this.gDelayEffectCompletionIntervalID != -1 || this.gCurrentTransitionObject.callbackID != undefined && this.gCurrentTransitionObject.callbackID != -1)))
  2358.       {
  2359.          return false;
  2360.       }
  2361.       if(this.gDelayEffectCompletionIntervalID != -1)
  2362.       {
  2363.          clearInterval(this.gDelayEffectCompletionIntervalID);
  2364.       }
  2365.       this.gDelayEffectCompletionIntervalID = -1;
  2366.       this.effectComplete(this,100);
  2367.    }
  2368.    this.gTransitionTimeChecker = getTimer();
  2369.    transitionObject.callbackID = -1;
  2370.    if(transitionObject.fromDuration < 0 && (transitionObject.imageEffectDuration < 0 || transitionObject.imaegEffectType == "none" || transitionObject.imageEffectType == ""))
  2371.    {
  2372.       return false;
  2373.    }
  2374.    var _loc4_ = this.getCachedView(transitionObject.toViewName);
  2375.    if(_loc4_ != null && (_loc4_.clip == undefined || _loc4_.clip == null))
  2376.    {
  2377.       this.setClipToEndOfEffectView(transitionObject);
  2378.       return true;
  2379.    }
  2380.    if(_loc4_ == null && transitionObject.toViewName != "" && transitionObject.toViewName != undefined && transitionObject.imageEffectType != "Zoom")
  2381.    {
  2382.       var _loc3_ = new Array();
  2383.       _loc3_[0] = new Object();
  2384.       _loc3_[0].name = transitionObject.toViewName;
  2385.       _loc3_[0].x = transitionObject.toX;
  2386.       _loc3_[0].y = transitionObject.toY;
  2387.       _loc3_[0].zoom = transitionObject.toZoom;
  2388.       _loc3_[0].imagePath = transitionObject.toImagePath;
  2389.       if(_loc3_[0].imagePath == "")
  2390.       {
  2391.          _loc3_[0].imagePath = this._imagePath;
  2392.       }
  2393.       this.cacheViews(_loc3_,"");
  2394.       this.cacheNextView();
  2395.       _loc4_ = this.getCachedView(transitionObject.toViewName);
  2396.    }
  2397.    this.gCurrentTransitionObject = transitionObject;
  2398.    this.gCurrentTransitionObject.labelVisibility = this.gLabelVisibility;
  2399.    this.setLabelVisibility(false);
  2400.    transitionObject.intervalID = -1;
  2401.    if(transitionObject.fromDuration < 0)
  2402.    {
  2403.       this.gInTransition = true;
  2404.       if(transitionObject.imageEffectDuration > 0)
  2405.       {
  2406.          transitionObject.intervalID = setInterval(this,"doImageEffect",20,transitionObject);
  2407.       }
  2408.       else
  2409.       {
  2410.          if(transitionObject.imageEffectDuration != 0)
  2411.          {
  2412.             return false;
  2413.          }
  2414.          this.gCurrentTier_mc._visible = false;
  2415.          this.gCurrentTierOld_mc._visible = false;
  2416.          this.gCurrentTierBackground_mc._visible = false;
  2417.          this.doImageEffect(transitionObject);
  2418.       }
  2419.    }
  2420.    else
  2421.    {
  2422.       var _loc5_ = "this.doImageEffect";
  2423.       if(transitionObject.imageEffectDuration < 0 || transitionObject.imageEffectDuration == undefined || transitionObject.imageEffectType == "None" || transitionObject.imageEffectType == undefined)
  2424.       {
  2425.          _loc5_ = "this.callEffectCompleteCallback";
  2426.       }
  2427.       else
  2428.       {
  2429.          this.gInTransition = true;
  2430.       }
  2431.       var _loc6_ = this.gEnabled;
  2432.       this.setEnabled(true);
  2433.       this.zoomToView(transitionObject.fromX,transitionObject.fromY,transitionObject.fromZoom,transitionObject.fromDuration,10,_loc5_,transitionObject);
  2434.       this.setEnabled(_loc6_);
  2435.    }
  2436.    return true;
  2437. };
  2438. ZoomifyViewerClass.prototype.doImageEffect = function(transitionObject)
  2439. {
  2440.    if(transitionObject.intervalID != -1)
  2441.    {
  2442.       clearInterval(transitionObject.intervalID);
  2443.    }
  2444.    transitionObject.intervalID = -1;
  2445.    if(transitionObject.fromDuration >= 0 && transitionObject.zoomCompleteCallback != "" && transitionObject.zoomCompleteCallback != undefined)
  2446.    {
  2447.       transitionObject.zoomCompleteCallback(this);
  2448.    }
  2449.    if((transitionObject.toViewName == "" || transitionObject.toViewName == undefined) && transitionObject.imageEffectType != "Zoom")
  2450.    {
  2451.       return false;
  2452.    }
  2453.    var cachedView = this.getCachedView(transitionObject.toViewName);
  2454.    if(transitionObject.imageEffectDuration < 0 || transitionObject.imageEffectType == "none" || transitionObject.imageEffectType == "" || cachedView == null && transitionObject.imageEffectType != "Zoom")
  2455.    {
  2456.       this.gInTransition = false;
  2457.       return false;
  2458.    }
  2459.    transitionObject.intervalID = -1;
  2460.    transitionObject.startTime = getTimer();
  2461.    transitionObject.previousTime = transitionObject.startTime;
  2462.    transitionObject.toMovieClip = cachedView.clip;
  2463.    cachedView.clip._x = this.gOffscreenX;
  2464.    cachedView.clip._visible = true;
  2465.    transitionObject.fromMovieClip = this;
  2466.    transitionObject.startXScale = transitionObject.toMovieClip._xscale;
  2467.    transitionObject.startYScale = transitionObject.toMovieClip._yscale;
  2468.    this.setEnabled(false);
  2469.    this.gCurrentZoomTime = getTimer();
  2470.    if(transitionObject.imageEffectDuration == 0)
  2471.    {
  2472.       this.effectInterval(transitionObject);
  2473.    }
  2474.    else if(transitionObject.imageEffectType == "Zoom")
  2475.    {
  2476.       this.setEnabled(true);
  2477.       this.zoomToView(transitionObject.toX,transitionObject.toY,transitionObject.toZoom,transitionObject.imageEffectDuration,10,"this.setClipToEndOfEffectView",transitionObject);
  2478.       this.setEnabled(false);
  2479.    }
  2480.    else
  2481.    {
  2482.       transitionObject.intervalID = setInterval(this,"effectInterval",10,transitionObject);
  2483.    }
  2484.    return true;
  2485. };
  2486. ZoomifyViewerClass.prototype.effectInterval = function(transitionObject)
  2487. {
  2488.    var _loc5_ = getTimer();
  2489.    var _loc3_ = (_loc5_ - transitionObject.startTime) / transitionObject.imageEffectDuration;
  2490.    var _loc4_ = true;
  2491.    if(_loc3_ > 1)
  2492.    {
  2493.       _loc3_ = 1;
  2494.    }
  2495.    var _loc6_ = transitionObject.imageEffectType;
  2496.    if(transitionObject.imageEffectDuration == 0)
  2497.    {
  2498.       _loc6_ = "Cut";
  2499.    }
  2500.    switch(_loc6_)
  2501.    {
  2502.       case "Wipe":
  2503.          switch(transitionObject.imageEffectParam)
  2504.          {
  2505.             case "Left":
  2506.                transitionObject.toMovieClip._x = this.gViewWidth - _loc3_ * this.gViewWidth;
  2507.                transitionObject.toMovieClip._y = 0;
  2508.                break;
  2509.             case "Down":
  2510.                transitionObject.toMovieClip._y = _loc3_ * this.gViewHeight - this.gViewHeight;
  2511.                transitionObject.toMovieClip._x = 0;
  2512.                break;
  2513.             case "Up":
  2514.                transitionObject.toMovieClip._y = this.gViewHeight - _loc3_ * this.gViewHeight;
  2515.                transitionObject.toMovieClip._x = 0;
  2516.                break;
  2517.             case "Right":
  2518.             default:
  2519.                transitionObject.toMovieClip._x = _loc3_ * this.gViewWidth - this.gViewWidth;
  2520.                transitionObject.toMovieClip._y = 0;
  2521.          }
  2522.          break;
  2523.       case "Fly":
  2524.          switch(transitionObject.imageEffectParam)
  2525.          {
  2526.             case "DownLeft":
  2527.                transitionObject.toMovieClip._x = this.gViewWidth - _loc3_ * this.gViewWidth;
  2528.                transitionObject.toMovieClip._y = _loc3_ * this.gViewHeight - this.gViewHeight;
  2529.                break;
  2530.             case "DownRight":
  2531.                transitionObject.toMovieClip._y = _loc3_ * this.gViewHeight - this.gViewHeight;
  2532.                transitionObject.toMovieClip._x = _loc3_ * this.gViewWidth - this.gViewWidth;
  2533.                break;
  2534.             case "UpLeft":
  2535.                transitionObject.toMovieClip._y = this.gViewHeight - _loc3_ * this.gViewHeight;
  2536.                transitionObject.toMovieClip._x = this.gViewWidth - _loc3_ * this.gViewWidth;
  2537.                break;
  2538.             case "UpRight":
  2539.             default:
  2540.                transitionObject.toMovieClip._x = _loc3_ * this.gViewWidth - this.gViewWidth;
  2541.                transitionObject.toMovieClip._y = this.gViewHeight - _loc3_ * this.gViewHeight;
  2542.          }
  2543.          break;
  2544.       case "Fade":
  2545.          transitionObject.toMovieClip._x = 0;
  2546.          transitionObject.toMovieClip._y = 0;
  2547.          transitionObject.toMovieClip._alpha = _loc3_ * 100;
  2548.          break;
  2549.       case "Rotate":
  2550.          switch(transitionObject.imageEffectParam)
  2551.          {
  2552.             case "Left":
  2553.                transitionObject.toMovieClip._x = this.gViewWidth - _loc3_ * this.gViewWidth;
  2554.                transitionObject.toMovieClip._y = 0;
  2555.                transitionObject.toMovieClip._rotation = _loc3_ * parseInt(transitionObject.imageEffectParam2);
  2556.                break;
  2557.             case "Down":
  2558.                transitionObject.toMovieClip._y = _loc3_ * this.gViewHeight - this.gViewHeight;
  2559.                transitionObject.toMovieClip._x = 0;
  2560.                transitionObject.toMovieClip._rotation = _loc3_ * parseInt(transitionObject.imageEffectParam2);
  2561.                break;
  2562.             case "Up":
  2563.                transitionObject.toMovieClip._y = this.gViewHeight - _loc3_ * this.gViewHeight;
  2564.                transitionObject.toMovieClip._x = 0;
  2565.                transitionObject.toMovieClip._rotation = _loc3_ * parseInt(transitionObject.imageEffectParam2);
  2566.                break;
  2567.             case "Right":
  2568.                transitionObject.toMovieClip._x = _loc3_ * this.gViewWidth - this.gViewWidth;
  2569.                transitionObject.toMovieClip._y = 0;
  2570.                transitionObject.toMovieClip._rotation = _loc3_ * parseInt(transitionObject.imageEffectParam2);
  2571.                break;
  2572.             case "Scale":
  2573.                transitionObject.toMovieClip._x = 0;
  2574.                transitionObject.toMovieClip._y = 0;
  2575.                transitionObject.toMovieClip._rotation = _loc3_ * parseInt(transitionObject.imageEffectParam2);
  2576.                transitionObject.toMovieClip._xscale = _loc3_ * transitionObject.startXScale;
  2577.                transitionObject.toMovieClip._yscale = _loc3_ * transitionObject.startYScale;
  2578.                break;
  2579.             case "Still":
  2580.             default:
  2581.                transitionObject.toMovieClip._x = 0;
  2582.                transitionObject.toMovieClip._y = 0;
  2583.                transitionObject.toMovieClip._rotation = _loc3_ * parseInt(transitionObject.imageEffectParam2);
  2584.          }
  2585.          break;
  2586.       case "Squeeze":
  2587.          switch(transitionObject.imageEffectParam)
  2588.          {
  2589.             case "Horizontal":
  2590.                transitionObject.toMovieClip._x = 0;
  2591.                transitionObject.toMovieClip._y = 0;
  2592.                transitionObject.toMovieClip._xscale = _loc3_ * transitionObject.startXScale;
  2593.                break;
  2594.             case "Vertical":
  2595.                transitionObject.toMovieClip._x = 0;
  2596.                transitionObject.toMovieClip._y = 0;
  2597.                transitionObject.toMovieClip._yscale = _loc3_ * transitionObject.startYScale;
  2598.                break;
  2599.             case "Both":
  2600.             default:
  2601.                transitionObject.toMovieClip._x = 0;
  2602.                transitionObject.toMovieClip._y = 0;
  2603.                transitionObject.toMovieClip._xscale = _loc3_ * transitionObject.startXScale;
  2604.                transitionObject.toMovieClip._yscale = _loc3_ * transitionObject.startYScale;
  2605.          }
  2606.          break;
  2607.       case "Cut":
  2608.       default:
  2609.          _loc4_ = false;
  2610.          transitionObject.toMovieClip._x = 0;
  2611.          transitionObject.toMovieClip._y = 0;
  2612.    }
  2613.    if(_loc5_ > transitionObject.startTime + transitionObject.imageEffectDuration || _loc4_ == false)
  2614.    {
  2615.       if(transitionObject.intervalID != -1)
  2616.       {
  2617.          clearInterval(transitionObject.intervalID);
  2618.       }
  2619.       transitionObject.intervalID = -1;
  2620.       transitionObject.toMovieClip._rotation = 0;
  2621.       this.gCurrentTransitionObject = transitionObject;
  2622.       this.gDelayEffectCompletionIntervalID = setInterval(this,"setClipToEndOfEffectView",100,transitionObject);
  2623.       updateAfterEvent();
  2624.    }
  2625. };
  2626. ZoomifyViewerClass.prototype.setClipToEndOfEffectView = function(transitionObject)
  2627. {
  2628.    if(this.gDelayEffectCompletionIntervalID != -1)
  2629.    {
  2630.       clearInterval(this.gDelayEffectCompletionIntervalID);
  2631.       this.gDelayEffectCompletionIntervalID = -1;
  2632.    }
  2633.    var _loc3_ = true;
  2634.    this.gInTransition = false;
  2635.    if(this._imagePath != transitionObject.toImagePath + "/" && this._imagePath != transitionObject.toImagePath && transitionObject.toImagePath != "")
  2636.    {
  2637.       if(transitionObject.toMovieClip.gInitialized == true)
  2638.       {
  2639.          this.gPreserveCache = true;
  2640.          this.gSkipHeader = true;
  2641.          this.destroy();
  2642.          this.setImagePath(transitionObject.toImagePath);
  2643.          this.init();
  2644.          this.gSkipHeader = false;
  2645.          this.gPreserveCache = false;
  2646.          transitionObject.toMovieClip.getInitializationData(this);
  2647.          this._initialX = transitionObject.toX;
  2648.          this._initialY = transitionObject.toY;
  2649.          this._initialZoom = transitionObject.toZoom;
  2650.          this.buildPyramid(this.gImageWidth,this.gImageHeight,this.gPyramidType,this.gTileSize,this.gMinTier);
  2651.          this._initialX = 0;
  2652.          this._initialY = 0;
  2653.          this._initialZoom = -1;
  2654.          this.setEnabled(true);
  2655.          this.updateView(true);
  2656.          this.setEnabled(false);
  2657.       }
  2658.       else
  2659.       {
  2660.          _loc3_ = false;
  2661.          this.gPreserveCache = true;
  2662.          this.setImagePath(transitionObject.toImagePath);
  2663.          this._initialX = transitionObject.toX;
  2664.          this._initialY = transitionObject.toY;
  2665.          this._initialZoom = transitionObject.toZoom;
  2666.          this.setEnabled(true);
  2667.          this.setView(transitionObject.toX,transitionObject.toY,transitionObject.toZoom);
  2668.          this.updateView(true);
  2669.          this.setEnabled(false);
  2670.          this.gPreserveCache = false;
  2671.       }
  2672.    }
  2673.    else
  2674.    {
  2675.       this.setEnabled(true);
  2676.       this.setView(transitionObject.toX,transitionObject.toY,transitionObject.toZoom);
  2677.       this.updateView(true);
  2678.       this.setEnabled(false);
  2679.    }
  2680.    this.gInTransition = true;
  2681.    if(_loc3_ == true)
  2682.    {
  2683.       this.gCurrentTransitionObject.callbackID = this.registerCallback("DownloadComplete","this.effectComplete");
  2684.       this.checkTileQueue();
  2685.       updateAfterEvent();
  2686.    }
  2687.    else
  2688.    {
  2689.       this.gCurrentTransitionObject.callbackID = -1;
  2690.       this.effectComplete(this,100);
  2691.    }
  2692. };
  2693. ZoomifyViewerClass.prototype.effectComplete = function(instance, percentComplete)
  2694. {
  2695.    if(percentComplete == 100 && instance == this)
  2696.    {
  2697.       if(this.gCurrentTransitionObject.callbackID != -1)
  2698.       {
  2699.          this.unregisterCallback("DownloadComplete",this.gCurrentTransitionObject.callbackID);
  2700.       }
  2701.       this.gCurrentTransitionObject.callbackID = -1;
  2702.       this.gCurrentTier_mc._visible = true;
  2703.       this.gCurrentTierOld_mc._visible = true;
  2704.       this.gCurrentTierBackground_mc._visible = true;
  2705.       this.gInTransition = false;
  2706.       this.setEnabled(true);
  2707.       this.updateView(true);
  2708.       this.setLabelVisibility(this.gCurrentTransitionObject.labelVisibility);
  2709.       var _loc2_ = getTimer() - this.gTransitionTimeChecker;
  2710.       this.callEffectCompleteCallback();
  2711.       updateAfterEvent();
  2712.       this.gMoveTransitionClipDelayID = -1;
  2713.       if(this.gCurrentTransitionObject.imageEffectDuration == 0 && this.gDoImmediateClipRemoval == true)
  2714.       {
  2715.          this.moveTransitionClipDelay();
  2716.       }
  2717.       else
  2718.       {
  2719.          this.gMoveTransitionClipDelayID = setInterval(this,"moveTransitionClipDelay",1);
  2720.       }
  2721.    }
  2722. };
  2723. ZoomifyViewerClass.prototype.moveTransitionClipDelay = function()
  2724. {
  2725.    if(this.gMoveTransitionClipDelayID != -1)
  2726.    {
  2727.       clearInterval(this.gMoveTransitionClipDelayID);
  2728.    }
  2729.    this.gCurrentTransitionObject.toMovieClip._x = this.gOffscreenX;
  2730.    this.gCurrentTransitionObject.toMovieClip._visible = false;
  2731. };
  2732. ZoomifyViewerClass.prototype.callEffectCompleteCallback = function()
  2733. {
  2734.    if(this.gCurrentTransitionObject.toDuration < 0)
  2735.    {
  2736.       if(this.gCurrentTransitionObject.fromDuration >= 0 && this.gCurrentTransitionObject.zoomCompleteCallback != "" && this.gCurrentTransitionObject.zoomCompleteCallback != undefined)
  2737.       {
  2738.          this.gCurrentTransitionObject.zoomCompleteCallback(this,this.gCurrentTransitionObject);
  2739.       }
  2740.    }
  2741.    else if(this.gCurrentTransitionObject.imageEffectCompleteCallback != "" && this.gCurrentTransitionObject.imageEffectCompleteCallback != undefined)
  2742.    {
  2743.       this.gCurrentTransitionObject.imageEffectCompleteCallback(this,this.gCurrentTransitionObject);
  2744.    }
  2745. };
  2746. ZoomifyViewerClass.prototype.zoomToView = function(x, y, zoom, duration, intervalRate, callback, callbackData)
  2747. {
  2748.    if(this.gEnabled == false)
  2749.    {
  2750.       return undefined;
  2751.    }
  2752.    if(this.gInitialized == true)
  2753.    {
  2754.       this.stopZoomToView();
  2755.       if(zoom == -1)
  2756.       {
  2757.          zoom = this.calculateScreenZoom();
  2758.       }
  2759.       this.gStartZoomX = this.getX();
  2760.       this.gStartZoomY = this.getY();
  2761.       this.gStartZoomZoom = this.getZoom();
  2762.       this.gCurrentZoomX = this.getX();
  2763.       this.gCurrentZoomY = this.getY();
  2764.       this.gCurrentZoomZoom = this.getZoom();
  2765.       this.gEndZoomX = x;
  2766.       this.gEndZoomY = y;
  2767.       this.gEndZoomZoom = zoom;
  2768.       this.gZoomDuration = duration;
  2769.       this.gZoomStartTime = getTimer();
  2770.       this.gCurrentZoomTime = this.gZoomStartTime;
  2771.       this.gZoomStepX = -1;
  2772.       this.gZoomToViewIntervalID = setInterval(this,"zoomToViewInterval",intervalRate,callback,callbackData);
  2773.       this.gOldMaxZoom = this._maxZoom;
  2774.       this.gOldMinZoom = this._minZoom;
  2775.       if(this.gOldMaxZoom < zoom)
  2776.       {
  2777.          this._maxZoom = zoom;
  2778.       }
  2779.       if(this.gOldMinZoom != -1 && this.gOldMinZoom > zoom || this.gOldMinZoom == -1 && zoom > this.calculateScreenZoom())
  2780.       {
  2781.          this._minZoom = zoom;
  2782.       }
  2783.       this.gCurrentZoomToViewStep = 0;
  2784.    }
  2785.    else
  2786.    {
  2787.       this.gSavedZoomToView = true;
  2788.       this.gEndZoomX = x;
  2789.       this.gEndZoomY = y;
  2790.       this.gEndZoomZoom = zoom;
  2791.       this.gZoomDuration = duration;
  2792.       this.gZoomIntervalRate = intervalRate;
  2793.    }
  2794. };
  2795. ZoomifyViewerClass.prototype.zoomToViewInterval = function(callback, callbackData)
  2796. {
  2797.    var currentTime = getTimer();
  2798.    var timeElapsed = currentTime - this.gZoomStartTime;
  2799.    var stepNumber = this.gCurrentZoomToViewStep + (this.gZoomDuration - timeElapsed) / (currentTime - this.gCurrentZoomTime) + 1;
  2800.    this.gCurrentZoomToViewStep = this.gCurrentZoomToViewStep + 1;
  2801.    if(this.gZoomDuration > 0)
  2802.    {
  2803.       this.gCurrentZoomX = this.gStartZoomX + timeElapsed * (this.gEndZoomX - this.gStartZoomX) / this.gZoomDuration;
  2804.       this.gCurrentZoomY = this.gStartZoomY + timeElapsed * (this.gEndZoomY - this.gStartZoomY) / this.gZoomDuration;
  2805.    }
  2806.    else
  2807.    {
  2808.       this.gCurrentZoomX = this.gEndZoomX;
  2809.       this.gCurrentZoomY = this.gEndZoomY;
  2810.    }
  2811.    var zoomBig;
  2812.    var zoomSmall;
  2813.    var zoomScale;
  2814.    if(this.gEndZoomZoom == this.gStartZoomZoom)
  2815.    {
  2816.       zoomScale = 1;
  2817.       this.gCurrentZoomZoom = this.gEndZoomZoom;
  2818.    }
  2819.    else if(this.gEndZoomZoom > this.gStartZoomZoom)
  2820.    {
  2821.       zoomBig = this.gEndZoomZoom;
  2822.       zoomSmall = this.gStartZoomZoom;
  2823.       zoomScale = Math.pow(2.718281828459045,Math.log(zoomBig / zoomSmall) / stepNumber);
  2824.       this.gCurrentZoomZoom = this.getZoom() * zoomScale;
  2825.    }
  2826.    else
  2827.    {
  2828.       zoomSmall = this.gEndZoomZoom;
  2829.       zoomBig = this.gStartZoomZoom;
  2830.       zoomScale = Math.pow(2.718281828459045,Math.log(zoomBig / zoomSmall) / stepNumber);
  2831.       this.gCurrentZoomZoom = this.getZoom() / zoomScale;
  2832.    }
  2833.    this.gCurrentZoomTime = currentTime;
  2834.    var atDestination = true;
  2835.    var tempEnabled = this.gEnabled;
  2836.    this.setEnabled(true);
  2837.    if(this.gCurrentZoomX < this.gEndZoomX - 0.01 || this.gCurrentZoomX > this.gEndZoomX + 0.01 || this.gCurrentZoomY < this.gEndZoomY - 0.01 || this.gCurrentZoomY > this.gEndZoomY + 0.01 || this.gCurrentZoomZoom < this.gEndZoomZoom - 0.01 || this.gCurrentZoomZoom > this.gEndZoomZoom + 0.01)
  2838.    {
  2839.       this.gPanPositionX = this.gCurrentZoomX;
  2840.       this.gPanPositionY = this.gCurrentZoomY;
  2841.       this.fillView();
  2842.       this.gZoomFactor = zoomScale;
  2843.       if(this.gEndZoomZoom > this.gStartZoomZoom)
  2844.       {
  2845.          this.zoomIn();
  2846.       }
  2847.       else if(this.gEndZoomZoom < this.gStartZoomZoom)
  2848.       {
  2849.          this.zoomOut();
  2850.       }
  2851.       this.gZoomFactor = -1;
  2852.       updateAfterEvent();
  2853.       atDestination = false;
  2854.    }
  2855.    if(getTimer() - this.gZoomStartTime >= this.gZoomDuration || atDestination == true)
  2856.    {
  2857.       if(callback != "this.doImageEffect")
  2858.       {
  2859.          this.setView(this.gEndZoomX,this.gEndZoomY,this.gEndZoomZoom);
  2860.          this.updateView(true);
  2861.       }
  2862.       else
  2863.       {
  2864.          this.gPanPositionX = this.gEndZoomX;
  2865.          this.gPanPositionY = this.gEndZoomY;
  2866.          this.fillView();
  2867.       }
  2868.       if(callback != "" && callback != undefined)
  2869.       {
  2870.          callback(callbackData);
  2871.       }
  2872.       this.stopZoomToView();
  2873.    }
  2874.    this.setEnabled(tempEnabled);
  2875. };
  2876. ZoomifyViewerClass.prototype.stopZoomToView = function()
  2877. {
  2878.    if(this.gZoomToViewIntervalID != -1)
  2879.    {
  2880.       clearInterval(this.gZoomToViewIntervalID);
  2881.       this.gZoomToViewIntervalID = -1;
  2882.       this.gHaltViewMessages = false;
  2883.       this._maxZoom = this.gOldMaxZoom;
  2884.       this._minZoom = this.gOldMinZoom;
  2885.    }
  2886. };
  2887. ZoomifyViewerClass.prototype.sendMessage = function(mesg)
  2888. {
  2889.    if(this.gHaltViewMessages == false && mesg != this.gLastViewSent && this.gEnabled == true)
  2890.    {
  2891.       if(this.gLastViewSent != "First Message")
  2892.       {
  2893.          var i = 0;
  2894.          while(i < this.gCommServerCallback.length)
  2895.          {
  2896.             this.gCommServerCallback[i](mesg);
  2897.             i++;
  2898.          }
  2899.       }
  2900.       this.gLastViewSent = mesg;
  2901.    }
  2902. };
  2903. ZoomifyViewerClass.prototype.receiveMessage = function(mesg)
  2904. {
  2905.    var messageArray = mesg.split(":");
  2906.    if(messageArray[1] == "setView")
  2907.    {
  2908.       if(this.gZoomToViewIntervalID != -1)
  2909.       {
  2910.          clearInterval(this.gZoomToViewIntervalID);
  2911.          this.gZoomToViewIntervalID = -1;
  2912.       }
  2913.       this.gHaltViewMessages = true;
  2914.       this.zoomToView(parseFloat(messageArray[2]),parseFloat(messageArray[3]),parseFloat(messageArray[4]),2000,10,"","");
  2915.    }
  2916.    else
  2917.    {
  2918.       var i = 0;
  2919.       while(i < this.gCommServerMessageReceivedCallback.length)
  2920.       {
  2921.          this.gCommServerMessageReceivedCallback[i](messageArray);
  2922.          i++;
  2923.       }
  2924.    }
  2925. };
  2926.